简体   繁体   English

写入Excel文件错误

[英]Writing to excel file error

So I'm attempting to write a big ol' bunch of records I pulled out of an SQL database and sorted to an excel document using C#. 因此,我试图写大量的记录,这些记录是我从SQL数据库中提取出来的,并使用C#排序为excel文档。

The problem I'm having is it works fine for exactly 207159 rows. 我遇到的问题是,它恰好可以在207159行上正常工作。 Any more than that and it throws up an error, 0x800A03EC 除此之外,还会引发错误,0x800A03EC

Clearly it's not getting stuck on the old Excel row limit. 显然,它不会卡在旧的Excel行限制上。 Clearly it's not getting stuck on the new Excel row limit. 显然,它不会卡在新的Excel行限制上。 I'm completely stumped on this one! 我完全迷住了这个!

I have somewhere in the region of 350 000 records to write to an Excel document. 我在350 000条记录中的某处要写入Excel文档。

The error is occurring during the call to set the value of the range property of the sheet. 在设置工作表的range属性值的调用期间发生错误。 It won't do it when it is higher than the particular number I am passing to it. 当它高于我传递给它的特定数字时,它将不会执行此操作。 Any suggestions? 有什么建议么?

UPDATE: 更新:

I solved this by calling the ToShortDateString() method of DateTime. 我通过调用DateTime的ToShortDateString()方法解决了这一问题。 It didn't like the time element of the DateTime. 它不喜欢DateTime的时间元素。 Strange really as the time was always 00:00:00 时间总是00:00:00真的很奇怪

I've recently created a report that outputs to excel and came accross a similar issue before. 我最近创建了一份报告,该报告的输出非常出色,并且之前遇到过类似的问题。

The error code 0x800A03EC (or -2146827284) means NAME_NOT_FOUND; 错误代码0x800A03EC(或-2146827284)表示NAME_NOT_FOUND; you've asked for something, and Excel can't find it. 您要求提供某些东西,而Excel找不到它。

Hopefully the code I came up with to solve a similar issue can be of some assistance to you. 希望我提出来解决类似问题的代码可以对您有所帮助。

                    try
                    {

                     //MyData

                    catch (Exception COMException_HRESULT)
                    {
                        Console.Write(" 0x800AC472 is the VBA_E_IGNORE error that is returned whenever an object model call is invoked while the property browser is suspended.", COMException_HRESULT);

                    }

Is the 207159 row always the same or is it a different row? 207159行是否总是相同或不同? On that had the same problem: HRESULT: 0x800A03EC on Worksheet.range 在上面有同样的问题: HRESULT:Worksheet.range上的0x800A03EC

Used ToShortDateString() method of DateTime. 使用DateTime的ToShortDateString()方法。 The problem was the time element of the datetime, which it didn't like for some reason 问题是日期时间的时间元素,由于某种原因它不喜欢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM