有关第三方导数据的问题?
有没有人用过第三方控件导数据的问题我用的是他自代的...可是导的数据量大的时候就会出问题..我昨天用这个导5000多条数据还可以..但是到10000条数据的时候就读不来导出的Excel了..有人用过这个问题吗?帮看一下
//方法二
private void simpleButton2_Click(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString();
string fileName = ShowSaveFileDialog("Microsoft Excel Document", "Microsoft Excel|*.xls");
if (fileName != null && fileName != "")
{
ExportTo(fileName, gridView1);
OpenFile(fileName);
}
label3.Text = DateTime.Now.ToString();
}
public void OpenFile(string fileName)
{
if (MessageBox.Show("是否打开文件?", "导出为...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = fileName;
process.StartInfo.Verb = "Open";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
}
catch
{
MessageBox.Show("文件打开错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
//<sbExportToxls>
public void ExportTo(string filename, GridView gridview)
{
Cursor currentCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
IExportProvider provider = new ExportXlsProvider(filename);
BaseExportLink link = gridview.CreateExportLink(provider);
(link as GridViewExportLink).ExpandAll = true;
link.ExportTo(true);
provider.Dispose();
Cursor.Current = currentCursor;
}
public string ShowSaveFileDialog(string title, string filter)
{
SaveFileDialog dlg = new SaveFileDialog();
string name = System.Windows.Forms.Application.ProductName;
int n = name.LastIndexOf(".") + 1;
if (n > 0) name = name.Substring(n, name.Length - n);
dlg.Title = "导出为" + title;
dlg.FileName = name;
dlg.Filter = filter;
if (dlg.ShowDialog() == DialogResult.OK) return dlg.FileName;
return "";
}
#endregion