我现在从一个dt里面把数据导出至excel,数据量超过65535行, excel一个sheet只能显示65535行,怎么从一个dt里面导出多个excel文件啊,?!

解决方案 »

  1.   

    控制一下行数,根据行数判断一下,生成不同的EXCEL文件。
      

  2.   

    在生成的时候,每一个保存的时候,会有一个Response.End();这样,就没有办法进行下一次循环了啊,
      

  3.   

    For k = 0 To arry.Count - 1
                    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,我感觉还是你的循环设定的问题.
      

  4.   

    我是用的这样的方法,而不是调用 excel程序,那样,不一定都能成功的.winform和webform不一样啊.我用的是这样的.,'
    导出的程序:
    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();
      

  5.   

    最后一句应是HttpContext.Current.Response.End();
      

  6.   

    owc导到excel 客户端下载 根据需要是否删除(或者根据你要保存的时间)