Here’s what I want to do:
Hi,
Hi,
Cells.InsertRange works as MS Excel.
If you want to keep the width of column K,L,M, Please use Cells.InsertColumns method.
C#
private static void InsertRange(Range range)
{
Cells cells = range.Worksheet.Cells;
//CellArea ca = new CellArea();
//ca.StartRow = range.FirstRow;
//ca.EndRow = cells.MaxRow;
//ca.StartColumn = range.FirstColumn + range.ColumnCount;
//ca.EndColumn = cells.MaxColumn;
// cells.InsertRange(ca, range.ColumnCount, ShiftType.Right, true);
cells.InsertColumns(range.FirstColumn, range.ColumnCount);
}
I can't use InsertColumns, because that would affect the entire sheet (i.e. rows that are above and below the range I am duplicating will also be affected).
Using InsertRange, with ShiftRight, I get the desired effect, except for the column widths, i.e. only the rows that the range span will get effected. For me, it seems weird that the columns to the right of the range has their widths changed.
By the way, you say that Aspose works like MS Excel in this regard. What is the Excel equivalent of InsertRange?
Thanks!
/Fredrik
Hello again!
Hi,
I have added your comments in our database. Hopefully, you will get an update asap.
Hi,
If you insert range in Ms-Excel, Ms-Excel will not copy the column width and style.
Yes, you are right. I had to manually "remember" the column widths to the right and reset them after the insertion had been made.
Thanks!
/Fredrik