我正在开展一项小任务,只需将数据从SQL数据库复制到Excel即可。对于一个工作簿,我得到错误:HRESULT:0x800A03EC 我的直觉告诉我,在那个单元格中,Excel试图解决一个公式,因为他从数据库中获取了这些字符。我如何无法擅长从vb.net解决配方师并告诉他只是复制他得到的数据?
问题应该在这里:
For Each dr In Table.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In Table.Columns
colIndex += 1
'08/2016 MM Byte[] können nicht in Excel exportiert werden
If Not System.Type.GetType("System.Byte[]").Equals(dr(dc.ColumnName).GetType) Then
oWS.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Else
oWS.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName).ToString
End If
Next
任何举行将非常感谢!谢谢!
答案 0 :(得分:0)
解决了它们,只是比较上面的代码和这个:
For Each dr In Table.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In Table.Columns
colIndex += 1
If Not System.Type.GetType("System.Byte[]").Equals(dr(dc.ColumnName).GetType) Then
Try
oWS.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Catch ex As Exception
If System.Type.GetType("System.String").Equals(dr(dc.ColumnName).GetType) Then
oWS.Cells(rowIndex + 1, colIndex) = """" + dr(dc.ColumnName) + """"
Else
'Exception konnte nicht aufgelöst werden, weiter werfen
Throw ex
End If
End Try
Else
oWS.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName).ToString
End If
Next
Next