[英]Excel saves file, but throws error on opening it: “We found a prob-lem with some content in …”
I was able to save a workbook, but then when I reopened it, Excel complained, "We found a problem with some content in 'filename'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes." 我能够保存一个工作簿,但是当我重新打开它时,Excel抱怨说:“我们在'文件名'中发现了一些内容问题。您是否希望我们尝试尽可能地恢复?如果您信任源文件,在此工作簿中,单击“是”。
"Yes" (ie, recover) causes offending Drawings/Shapes/Charts to be deleted. “是”(即,恢复)将导致违规的工程图/图形/图表被删除。
The following describes the cause of my problem and its cure. 以下描述了我的问题的原因及其解决方法。
I had a user-defined worksheet function (UDF) that returned an array of values that was displayed in a chart. 我有一个用户定义的工作表函数(UDF),该函数返回了在图表中显示的值的数组。
The UDF was setting some of these values to the impossible value of 2.69653970229349E+308 (apparently a dll was returning 1.#QNAN which Excel turned into 2.69653970229349E+308). UDF将其中一些值设置为2.69653970229349E + 308的不可能值(显然dll返回1.#QNAN,Excel转换为2.69653970229349E + 308)。
Amazingly, Excel allowed this value to be saved in the cell, and the workbook to be saved. 令人惊讶的是,Excel允许将此值保存在单元格中,并保存工作簿。 However, when opening the workbook, the error was received, and the offending chart was deleted during the "recovery". 但是,在打开工作簿时,收到错误,并且在“恢复”期间删除了有问题的图表。
The cure was to ensure only realistic values are displayed in a chart. 解决办法是确保图表中仅显示实际值。
Here is code redacted from the rather large VBA project. 这是从相当大的VBA项目中删除的代码。
'Global array, Values returned by the UDF
Public MainReturnValues(1 To 57, 1 To 2) As Variant
Public Function MainWorksheetFunction( _
i_rRangeWithInputData As Range _
) As Variant
'[... Process input data ...]
'Load global array MainReturnValues(,), i.e., values returned by the UDF
LoadMainWorksheetFunctionReturnValues
'Now load UDF return values
MainWorksheetFunction = MainReturnValues
End Function
'Load global array MainReturnValues(,), i.e., values returned by the UDF
Private Function LoadMainWorksheetFunctionReturnValues( _
) As Boolean
Dim l_vErrNull As Variant
Dim l_dChartXs(1 To 57) As Double, _
l_dChartYs(1 To 57) As Double
Dim c As Long, _
r As Long
'~~~~~~~ First fill area with xlErrNull to Prevent Log Chart Graphing 0 Errors
'~~~~~~~ Excel will "pick up the pen" when cells contain CVErr(xlErrNull)
l_vErrNull = CVErr(xlErrNull)
For r = LBound(MainReturnValues, 1) To UBound(MainReturnValues, 1)
For c = LBound(MainReturnValues, 2) To UBound(MainReturnValues, 2)
MainReturnValues(r, c) = l_vErrNull
Next c
Next r
'~~~~~~~ End First fill area with xlErrNull ~~~~~~~
'[... Load values into l_dChartXs() and l_dChartYs() using C# dll ...]
For r = 1 To 57
'Don't try to plot ridiculous values. I suspect this causes this error:
'"We found a problem with some content in 'aaa.xlsb'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."
On Error Resume Next 'Catch 1.#QNAN
If ((l_dChartXs(r) > 1E+308) Or (l_dChartYs(r) > 1E+308)) Then
Else 'Value is not ridiculous
On Error GoTo 0
'Xs in first column
MainReturnValues(r, 1) = l_dChartXs(r)
'Ys in second column
MainReturnValues(r, 2) = l_dChartYs(r)
End If
Next r
LoadMainWorksheetFunctionReturnValues = True
Exit Function
I hope this helps someone. 我希望这可以帮助别人。
I tried looking solution for this all over the internet ,My Workbook was rather simple system generated .xls file with no shapes and chart, Excel was able to save it as .xlsx but was unable to open it without recovering contents 我尝试在整个Internet上寻找解决方案,我的工作簿是相当简单的系统生成的.xls文件,没有形状和图表,Excel能够将其保存为.xlsx,但无法打开它而没有恢复内容
I end up saving file as CSV and then later saved that CSV as xlsx I thought since CSV is almost like a text file with comma seprated values this might work for simple sheets with values 我最终将文件另存为CSV,然后又将其另存为xlsx,我认为这是因为CSV几乎就像是带有逗号分隔值的文本文件,这可能适用于带有值的简单工作表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.