Hi.
I am using Aspose.Cell to dealing with Excel SpreadSheet, and I want to put a single value (any like “value1”) in a full row or full column. I want something like this:
worksheet.Cells.Rows[2].value=“Value1”;
Value1
would insert in full row no 2, without cell , row or column iteration. I mean ,is there a single line function to do it without iteration?
There are some ways to accomplish your task in one go. For example, you may create a range based on your desired cells area (e.g. one whole row or column) and then put one common value to all the cells in that row/column. Another way can be, set a shared formula (to insert a constant string value) to your desired range of cells (for a row/col), etc.
See the sample code to accomplish the task using Range object:
e.g
Sample code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Create a range based on whole row
Range range = worksheet.Cells.CreateRange("A1:XFD1");
//insert common value.
range.Value = "value1";
//Create a range based for column, you may change it accordingly
range = worksheet.Cells.CreateRange("A1:A1000");
//insert common value.
range.Value = "value1";
workbook.Save("e:\\test2\\out1.xlsx");
Hope, this helps a bit.