Hi,
Well, I tried your scenario a bit using the following code and it works fine. I did not find any issue for generating both xls or xlsx files. The process is big and does take a little time (less than 40 seconds) but it works fine without any error. I have filled 10000 * 200 records and format a range of cells with your mentioned code. I have tested it with the attached version. Here is my sample code:
Sample code: Workbook workbook = new Workbook();
Color color = Color.FromArgb(255, 250, 223);
workbook.ChangePalette(color, 55);
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
int rows = 10000;
int numberOfColumns = 200;
//Fill Data in 10000 * 200 matrix.
for (int i = 0; i <= rows; i++)
{
for (int j = 0; j <= numberOfColumns; j++)
{
cells[i, j].PutValue(i.ToString() + "," + j.ToString());
}
}
//Apply to range style.
Range objRangeData = worksheet.Cells.CreateRange(0, 0,1000, 50);
objRangeData.Name = "DataRange";
Aspose.Cells.Style StyleDataRange = workbook.Styles[workbook.Styles.Add()];
StyleDataRange.Font.Name = "Arial";
StyleDataRange.Font.Size = 8;
StyleDataRange.Font.Color = System.Drawing.Color.Black;
StyleDataRange.HorizontalAlignment = TextAlignmentType.Left;
StyleDataRange.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
StyleDataRange.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
StyleDataRange.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
StyleDataRange.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
StyleDataRange.ForegroundColor = System.Drawing.Color.FromArgb(255, 250, 223);
StyleDataRange.Pattern = BackgroundType.Solid;
//Define a style flag struct.
StyleFlag flagDataRange = new StyleFlag();
flagDataRange.CellShading = true;
flagDataRange.FontName = true;
flagDataRange.FontSize = true;
flagDataRange.FontColor = true;
flagDataRange.HorizontalAlignment = true;
flagDataRange.Borders = true;
flagDataRange.ShrinkToFit = true;
flagDataRange.WrapText = true;
objRangeData.ApplyStyle(StyleDataRange, flagDataRange);
workbook.Save("e:\\test\\ntestmem_test.xlsx");
If you still find any issue, kindly create a sample project and post it here, we will check it soon.
Thank you.
Amjad Sahi
Support Developer,
Aspose Sialkot Team
Contact Us