Writing data to an existing sheet...?

I have been unable to locate a sample that shows how to open an existing workbook, select a specific sheet, and write new rows at a specific place in that sheet. Any assistance (particularly a pointer to code samples!) MOST appreciated.


This message was posted using Aspose.Live 2 Forum

Hi,

Thanks for your inquiry.

Here is a sample code for your need.

Workbook workbook = new Workbook();
workbook.Open(“d:\test\MyFile.xls”);
//Get the second sheet.
Worksheet worksheet = workbook.Worksheets[1];
Cells cells = worksheet.Cells;
cells.InsertRow(1);

cells[“A12”].PutValue(“ABC Pubshr.”);
cells[“B12”].PutValue(“UK”);
cells[“C12”].PutValue(“1”);
cells[“D12”].PutValue(“5”);
cells[“E12”].PutValue(112);
cells[“F12”].PutValue(4);
cells[“G12”].PutValue(100);
cells[“H12”].PutValue(200);
cells[“I12”].PutValue(.84);

//… Your code goes here.


workbook.Save(“d:\test\outBook1.xls”);


For further reference, please check some documentation links.

http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/adding-data-to-cells.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/insertingdeleting-rows-and-columns.html

Also, you may check online demos:

Thank you.