We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Insert blocks of cells

Thread ID:





63484 Jul 4,2007 04:25 PM UTC Jul 4,2007 08:23 PM UTC WinForms 1
Tags: XlsIO
Christian Nein
Asked On July 4, 2007 04:25 PM UTC


is it possible to insert only a block of cells, like this is possible in Excel? Example:

Excel.Range range1 = worksheet.get_Range(worksheet.Cells[6, 3], worksheet.Cells[15, 5]);
range1.Insert(Excel.XlInsertShiftDirection.xlShiftToRight); // this command inserts a block of 10x3 cells and ONLY shifts the cells located right to "range1" to the right

I only found commands to insert whole rows or columns. The problem here is that inserting a whole column does also move the cells top and bottom to the affected area which in this case is explicitly not wanted. Maybe I have to use some Move()-function?

Thanks in advance & best regards

Ajish [Syncfusion]
Replied On July 4, 2007 08:23 PM UTC

Hi Christian ,

Thank you for your interest in Essential XlsIO,

To insert a particular value at a cell range we need to do a rangemove operation to get the desired output and then insert the value. The following method will take a range, Inserted Value as input and shift the cells down.

private void MoveCellsDownAndInsert(IWorksheet sheet, IRange range, string value)
int iStartRow = range.LastRow;
int iStartCol = range.Column;
int iLastRow = sheet.UsedRange.End.Row;
int iLastCol = range.LastColumn;

IRange rangeToMove = sheet.Range[iStartRow, iStartCol, iLastRow, iLastCol];
rangeToMove.MoveTo(sheet.Range[range.Row + 1, range.Column]);
range.Value = value;


Here is a sample for your reference: http://websamples.syncfusion.com/samples/XlsIO.Windows/F63484/main.htm

Kindly take a look and let us know if this helps.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon