Hi Team,
I am unable to export the data in an .xlsx. The data size is huge(around 25000 and above). I tried 2 cells dlls. (8.5.1.0 and 8.8.2.0) . The page freezes/unresponsive(Aw Snap!).
Source: Aspose.Cells
TargetSite: Void AutoFitColumn(Int32)
Message: Invalid column index.
Here is the code snippet-
try {
Aspose.Cells.License licence = new Aspose.Cells.License();
string licenseFile = Server.MapPath("~/app_data/Aspose.Total.lic");
licence.SetLicense(licenseFile);
Workbook myWorkbook = new Workbook();
myWorkbook.Worksheets.RemoveAt(0);
Aspose.Cells.Style HeaderStyle = myWorkbook.Styles[myWorkbook.Styles.Add()];
HeaderStyle.Name = "HeaderStyle";
//WorksheetStyle myWorksheetStyle = null;
// myWorksheetStyle = myWorkbook.Styles.Add("HeaderStyle")
HeaderStyle.Font.Name = "MS Sans Serif";
HeaderStyle.Font.Size = 10;
//Styles for Work Sheets
//Header Style
Aspose.Cells.Style DefaultColumn = myWorkbook.Styles[myWorkbook.Styles.Add()];
DefaultColumn.Font.Name = "MS Sans Serif";
DefaultColumn.Font.Size = 10;
Aspose.Cells.Style dateupload = myWorkbook.Styles[myWorkbook.Styles.Add()];
dateupload.Font.Name = "MS Sans Serif";
dateupload.Font.Size = 10;
dateupload.Number = 22;
StyleFlag style3 = new StyleFlag();
style3.NumberFormat = true;
Worksheet myWorksheet = myWorkbook.Worksheets.Add("My Report");
//myWorksheet.Options.ActivePane = 2;
myWorksheet.IsSelected = true;
myWorksheet.ActiveCell = "A2";
//Adding columns to work sheet
// Index Column
myWorksheet.Cells.InsertColumn(0);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
// File Name Column
myWorksheet.Cells.InsertColumn(1);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
// Folder Path Column
myWorksheet.Cells.InsertColumn(2);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
// Date Uploaded Column
myWorksheet.Cells.InsertColumn(3);
myWorksheet.Cells.ApplyColumnStyle(0, dateupload, style3);
// RRD Admin User Column
if (reportType == "Me")
{
myWorksheet.Cells.InsertColumn(4);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
}
// File Size Column
myWorksheet.Cells.InsertColumn(5);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
// Page Count Column
myWorksheet.Cells.InsertColumn(6);
myWorksheet.Cells.ApplyColumnStyle(0, DefaultColumn, style3);
// Create the Header Row
myWorksheet.Cells.InsertRow(1);
myWorksheet.Cells["A1"].PutValue("Index Number", true);
myWorksheet.Cells["A1"].SetStyle(HeaderStyle);
myWorksheet.Cells["B1"].PutValue("File Name", true);
myWorksheet.Cells["B1"].SetStyle(HeaderStyle);
myWorksheet.Cells["C1"].PutValue("Folder Path", true);
myWorksheet.Cells["C1"].SetStyle(HeaderStyle);
myWorksheet.Cells["D1"].PutValue("Date Uploaded", true);
myWorksheet.Cells["D1"].SetStyle(dateupload);
myWorksheet.Cells["E1"].PutValue("User", true);
myWorksheet.Cells["E1"].SetStyle(HeaderStyle);
myWorksheet.Cells["F1"].PutValue("File Size (MB)", true);
myWorksheet.Cells["F1"].SetStyle(HeaderStyle);
myWorksheet.Cells["G1"].PutValue("Page Count", true);
myWorksheet.Cells["G1"].SetStyle(HeaderStyle);
DataTable dt = GenerateData(); // This contains data rows more than 20000
int rownumber = 1;
if (dt != null)
{
foreach (DataRow dr in dt.Rows)
{
myWorksheet.Cells.InsertRow(rownumber);
myWorksheet.Cells[rownumber, 0].PutValue(dr["Index"].ToString(), true);
myWorksheet.Cells[rownumber, 1].PutValue(dr["File Name"].ToString(), true);
myWorksheet.Cells[rownumber, 2].PutValue(dr["Path"].ToString(), true);
myWorksheet.Cells[rownumber, 3].PutValue(dr["Date Uploaded"].ToString(), true);
myWorksheet.Cells[rownumber, 4].PutValue(dr["User"].ToString(), true);
myWorksheet.Cells[rownumber, 5].PutValue(dr["File Size (MB)"].ToString(), true);
myWorksheet.Cells[rownumber, 6].PutValue(dr["Page Count"].ToString(), true);
myWorksheet.AutoFitColumn(rownumber); // Exception comes here which is thrown
rownumber++;
}
}
myWorksheet.AutoFitColumn(rownumber);
Please assist.