Okay, I did some more testing and figured a little more out. Here is the code that we use to generate our excel file:
|
|
//Set the license
Aspose.Excel.License objLicense = new Aspose.Excel.License();
objLicense.SetLicense(“Aspose.Excel.lic”);
//Create an instance of the ASPOSE excel designer ExcelDesigner objExcelDesigner = new ExcelDesigner();
//Open the template file
objExcelDesigner.Open(sTemplatePath + sTemplateFile);
//Set the datasource for the document
objExcelDesigner.SetDataSource(dsReport);
objExcelDesigner.SetDataSource(“Variable”, “Single Variable”);
//Build the document
objExcelDesigner.Process();
for(int i=0; i<30; i++)
{
objExcelDesigner.Excel.Worksheets[0].Cells[7,i].Style.ForegroundColor = Color.Red;
objExcelDesigner.Excel.Worksheets[0].Cells[7,i].Style.Pattern = BackgroundType.Solid;
}
//Save the document
objExcelDesigner.Save(sSaveFile, SaveType.OpenInExcel, FileFormatType.Default, this.Response);
|
As you can see in the for loop near the bottom of the code block I am setting the cell colors for all cells from 0 to 29.
Now shouldn’t I be able to do the same thing with:
|
|
objExcelDesigner.Excel.Worksheets[0].Cells.Rows[7].Style.ForegroundColor = Color.Red;
objExcelDesigner.Excel.Worksheets[0].Cells.Rows[7].Style.Font.Color = Color.Red;
|
When I use the above code it won’t color any of the cells that have been populated with the SmartMarkers. Though it will color the rest of the row where there are no smart markers. Is this a bug or just the way it works.
If I have to use the for loop how can I find out how many columns are in the spreadsheet?
Thank you for your time on this,
Martin