简体   繁体   中英

How to insert an empty row in excel spread sheet using GemBox?

This doesn't work:

sheet.Rows[onRow].InsertEmpty(1);

Where sheet is an instance of ExcelWorksheet, and onRow is an int. That seems to do nothing at all.

Can you try this sample code:

ExcelFile ef = new ExcelFile();
ExcelWorksheet ws = ef.Worksheets.Add("Sheet1");

ws.Cells["A1"].Value = "Test";

ws.Rows[0].InsertEmpty(1);

// "Test" value should now be moved to "A2" cell.
Console.WriteLine(ws.Cells["A2"].Value);

Does it work?
If it does then your problem is probably with something else, so you should update your question.

Also as an FYI, which version of GemBox.Spreadsheet are you using?
That method is obsolete in the latest version, instead the following is recommended:

sheet.Rows.InsertEmpty(onRow);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM