tags:

views:

52

answers:

1

m trying to break one large Excel spreadsheet into several. I've made good progress, but I'm running into some problems. Specifically, the values that get copied over don't retain their format (for instance, 40322 instead of 5/24/2010 and -101 instead of (101.00) ). I've tried using the style (see below) but that doesn't even get me the font, let alone the number format. Any help or a poke in the right direction would be appreciated.

There are 2 loops, one for row, one for column.

destinationSheet.Cells[i, j].Style = sourceSheet.Cells[i, j].Style;
+3  A: 

Instead of looping for each cell, you can copy/paste the entire range of cells using the pastespecial method.

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.pastespecial(VS.80).aspx

buckbova
Thanks, this solved more than one problem
Scott