Copy cell with style...

Topics: Developer Forum
Jan 9, 2009 at 9:06 PM
I have xlsx file with some cells. Cells have styles. There are some merged cells and cells with modified width.
How can I copy cells (with all slyles, width, merge etc.) from one package to another?

This code creates corrupted output file.

for (int i = 1; i < 3; i++ )
for (int j = 1; j < 5; j++)
//Copy cell from one package to cell from other package with all styles.
outSheet.Cell(j, i).Value = inSheet.Cell(j, i).Value;
outSheet.Cell(j, i).Style = inSheet.Cell(j, i).Style;
outSheet.Cell(j, i).StyleID = inSheet.Cell(j, i).StyleID;