Excel error HRESULT: 0x800A03EC while trying to get range with cell's name

后端 未结 12 1550
无人共我
无人共我 2020-11-30 12:30

I am working with Window Service project. that have to write data to a sheet in Excel file in a sequence times.

But sometimes, just sometimes, the service throw out

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 12:53

    I got the error with a space in a Sheet Name:

    using (var range = _excelApp.Range["Sheet Name Had Space!$A$1"].WithComCleanup())
    

    I fixed it by putting single quotes around Sheet Names with spaces:

    using (var range = _excelApp.Range["'Sheet Name Had Space'!$A$1"].WithComCleanup())
    

提交回复
热议问题