开发者

Excel interop writes excel files that contain "empty" cells

I have a c# tool that creates excel worksheets, which will be later read in again by another too开发者_JAVA百科l. This is done by using excel interop.

when reading the generated excel file, an exception stating: OleDbException: Too many fields defined.

it means that the file cannot be read in because there are too amny columns, but there should not be, as the real content only takes about 90 columns. As a workaround i deleted all the other columns manually in excel, and tried again to read it in. this works as expected, so that means that the generated excel does contain nonempty cells (which are shown as empty cells in excel...)

is there a way to tell the inerop not to create empty cells, or is there another reason i should check?

Many thanks Tom

PS: I am experiencing this problem with the 2003 interop libraries, while i've got Office 2007 installed.


I've Found the solution: The tool was copying ranges from one sheet to another.

The source range was properly defined: GetRange(fromWorkbookName, fromSheetName, A1, V20);

The destination cell hoever was adressed by: GetRange(toWorkbookName, toSheetName, A1).EntireRow;

In 2003 interop, this seemed no Problem. When doing this towards an xslx file i Office 2010, some "Empty" fields containing "#N/A" were created.

Nasty nasty...

anyhow the tool was not doing the copy/paste correctly (even excel itself warns you when you copy a range manually to an entire line). After correcting this it seems to work....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜