我现在从一个dt里面把数据导出至excel,数据量超过65535行, excel一个sheet只能显示65535行,怎么从一个dt里面导出多个excel文件啊,?!
解决方案 »
- C# FileStream BeginRead 异步如何取消
- C#编辑DataGridView后回车赋值 急急急!!!
- c# Socket Send Receive 边界问题?求高手解决!
- 在.net中如何获得excel一个单元格,并判断出该单元格是否是合并单元格呢?
- 学习讨论WinForm的开发
- 在Form1点击一个(button)按纽,出现另一个窗体Form2
- 怎么在定时器中更新LABEL的值,请看代码
- 各位高手,前辈门好啊。我是C#初学者,刚弄完了毕业设计的程序。请大家有空的话帮忙测试一下了。
- Csdn社区的疑问?
- 正则问题
- 求助:不能用 WMI 在本地或远程运行程序
- 关于常数定义......
Dim xlApp As New Excel.Application
xlBook = xlApp.Workbooks.Add
xlSheet = xlBook.Worksheets("sheet1")
strPath = _strExcelPath & "\" & k + 1 & ".xls"
Dim col As DataColumn
Dim colIndex As Integer = 0
For Each col In _ExcelDataSet.Tables(0).Columns
colIndex = colIndex + 1
xlApp.Cells(1, colIndex) = col.ColumnName
Next Dim row As DataRow
Dim rowIndex As Integer = 0
For Each row In _ExcelDataSet.Tables(0).Select(_strColumnName & "='" & Convert.ToString(arry(k)) & "'")
'
rowIndex = rowIndex + 1
colIndex = 0
For Each col In _ExcelDataSet.Tables(0).Columns
colIndex = colIndex + 1
xlApp.Cells(rowIndex, colIndex) = row(col.ColumnName)
Next Next xlBook.SaveAs(strPath, xlApp.ActiveWorkbook.FileFormat, "", "", xlApp.ActiveWorkbook.ReadOnlyRecommended, xlApp.ActiveWorkbook.CreateBackup, Excel.XlSaveAsAccessMode.xlShared.xlShared, xlApp.ActiveWorkbook.ConflictResolution, False, "", "") '
xlBook.Close()
xlApp.Quit()
xlApp = Nothing
Next
我是用WINFROM,我感觉还是你的循环设定的问题.
导出的程序:
FileName=FileName+"_"+DateTime.Now.Month+DateTime.Now.Day+DateTime.Now.Hour+DateTime.Now.Minute;
HttpContext.Current.Response.AddHeader("Content-Disposition","inline;filename="+HttpUtility.UrlEncode(FileName,System.Text.Encoding.UTF8)+".xls");
HttpContext.Current.Response.ContentType="application/ms-excel";
HttpContext.Current.Response.Write(Constants.vbCrLf);
foreach(DataRow dr in dt.Rows)
{
for(int j=0;j<dr.ItemArray.Length;j++)
HttpContext.Current.Response.Write(dr.ItemArray[j].ToString()+Constants.vbTab);
HttpContext.Current.Response.Write(Constants.vbCrLf);
}
HttpContext.Current.Response.Output.Close();