We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add/Set Column Data

Hello,

I’m trying to set a fix value for the entire column. Is there a way to do this without doing a loop through each cell/row?

Thanks.

Hi,


I think you may try to create your desired range of cells in the column and set the common value to all the cells in one go, see the sample code for your reference:
e.g
Sample code:

Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
Range range = cells.CreateRange(“A1:A1000”);
range.Value = “Testin…”;
workbook.Save(“e:\test2\outColumnData1.xlsx”);


Hope, this helps a bit.

Thank you.

Hi Amjad,

Thank you for the tips. I also found another alternative with the following code:




string formula = "=“Test123"”;

sheet.Cells[1,5].SetSharedFormula(formula, sheet.Cells.MaxDataRow, 1);




Any advice on which method is better in term of performance?

Hi,


Well, if you want to fill fixed/ common value into cells (in the column/row), my approach is better way for performance considerations. The Shared Formula approach is good but you would always need to calculate those formulas first to get the value at runtime or force MS Excel to recalculate the formulas when opening your output file into it which will surely take a little extra time.

Thank you.