問題描述
我正在使用 Window Service 項(xiàng)目.必須按順序?qū)?shù)據(jù)寫入 Excel 文件中的工作表.
I am working with Window Service project. that have to write data to a sheet in Excel file in a sequence times.
但有時(shí),只是有時(shí),服務(wù)在嘗試使用單元格名稱獲取范圍時(shí)拋出異常Exception from HRESULT: 0x800A03EC".
But sometimes, just sometimes, the service throw out the exception "Exception from HRESULT: 0x800A03EC" while it's trying to get range with cell's name.
我已經(jīng)把打開excel表格的代碼放在這里了.
I have put the code of opening excel sheet, and getting cell here.
- 操作系統(tǒng):window server 2003 Office:
- Microsoft Office 2003 sp2
1:打開excel表格
1: Opening excel sheet
m_WorkBook = m_WorkBooks.Open(this.FilePath, 0, false, 5,
"", "", true, Excels.XlPlatform.xlWindows, ";",
true, false, 0, true, 0, 0);
2:讓單元格寫入
protected object m_MissingValue = System.Reflection.Missing.Value;
Range range = m_WorkSheet.get_Range(cell.CellName, m_MissingValue);
// error from this method, and cell name is string.
推薦答案
錯(cuò)誤碼0x800A03EC
(或-2146827284)表示NAME_NOT_FOUND;換句話說,你已經(jīng)要求了一些東西,而 Excel 找不到它.
The error code 0x800A03EC
(or -2146827284) means NAME_NOT_FOUND; in other words, you've asked for something, and Excel can't find it.
這是一個(gè)通用代碼,它可以應(yīng)用于很多它找不到的東西,例如.當(dāng) PivotItem 未應(yīng)用過濾器時(shí),使用當(dāng)時(shí)無效的屬性(如 PivotItem.SourceNameStandard
)會拋出此錯(cuò)誤.Worksheets["BLAHBLAH"]
在工作表不存在等情況下會拋出此錯(cuò)誤.通常,您要求的是具有特定名稱且不存在的內(nèi)容.至于為什么,這需要你自己去挖掘.
This is a generic code, which can apply to lots of things it can't find e.g. using properties which aren't valid at that time like PivotItem.SourceNameStandard
throws this when a PivotItem doesn't have a filter applied. Worksheets["BLAHBLAH"]
throws this, when the sheet doesn't exist etc. In general, you are asking for something with a specific name and it doesn't exist. As for why, that will taking some digging on your part.
檢查您的工作表是否確實(shí)有您要求的范圍,或者 .CellName
肯定會返回您要求的范圍的名稱.
Check your sheet definitely does have the Range you are asking for, or that the .CellName
is definitely giving back the name of the range you are asking for.
這篇關(guān)于Excel 錯(cuò)誤 HRESULT: 0x800A03EC 嘗試使用單元格名稱獲取范圍的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!