How Do I Insert Cells

Does ASPOSE.Excel allow you to “insert” a column? If so how? I’d like to take my template then insert several cells keeping the data consistent for the cells to the right and left of the column I insert from.

Dear Steve,

Thanks for your consideration.

Do you mean the “Insert Column” feature in Excel?

For example, in your template you put data in cell A1 and B1. You insert a column between A and B column. Then a new column is inserted the data B1 is moved to C1. Now you can insert data in B1 without overriding the previous data.

If so, I have to say that this feature currently is not supported.

I will investigate this feature.

Has there been any progress on this?

I would also like to be able to insert rows, as well as columns. The use for this is that I want to be able to create a template with existing formatted information. and then insert a bunch of rows ABOVE that info, so that it gets pushed down, then I can go back into the new rows I have created and populate them with data.

Thanks,

Marc

Dear Marc,

Did your template contain chart, comments or formula? If yes, it’s difficult to implement the “Insert” feature as you need.

Otherwise, if your template only contains cell value, style or picture, I can provide these feature within one month and a half.

Is there any progress on this ? I have the same problem.

THX

Please check Cells.InsertRow and Cells.InsertColumn method.

@MadMorti,
Aspose.Excel is discontinued now and no more available. It is replaced by Aspose.Cells that provides a lot of features to insert/delete rows and columns. You can also insert/ multiple rows and columns along with the formatting. Here is an example that demonstrates the feature of inserting a row with formatting.

// Instantiating a Workbook object
// Opening the Excel file through the file stream
Workbook workbook = new Workbook();

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
Style style = workbook.CreateStyle();
style.Font.IsBold = true;
style.Pattern = BackgroundType.Solid;
style.ForegroundColor = Color.Yellow;

StyleFlag styleFlag = new StyleFlag();
styleFlag.All = true;
worksheet.Cells.Rows[0].ApplyStyle(style, styleFlag);

worksheet.Cells["A1"].Value = "Sample Data";

// Setting Formatting options
InsertOptions insertOptions = new InsertOptions();
insertOptions.CopyFormatType = CopyFormatType.SameAsAbove;

// Inserting a row into the worksheet at 3rd position
worksheet.Cells.InsertRows(1, 1, insertOptions);

worksheet.Cells["A2"].Value = "Sample Data 2";

// Saving the modified Excel file
workbook.Save("InsertingARowWithFormatting.out.xls");

For more information about inserting and deleting rows and columns refer to the following article:
Inserting and deleting rows and columns

Get the free trial version here:
Aspose.Cells for .NET (Latest Version)

Here is a link to an example solution that contains hundreds of examples to test different features of this new product.