一个excel突然打不开了,提示错误为:
Replaced Part: /xl/worksheets/sheet3.xml part with XML error. 灾难性故障 Line 2, column 82450988.
Removed Records: Formula from /xl/calcChain.xml part (Calculation properties)
Removed Records: Formula from /xl/calcChain.xml part (Calculation properties)
解决办法:
1、修改文件后缀名".xlxs"为".zip",解压,根据错误找到sheet3.xml文件
2、尝试使用浏览器打开(想让浏览器检测告诉我文件错误位置),但因为文件过大(80多M),根本打不开
3、写个程序A读取错误位置(java),代码如下:
</pre><pre name="code" class="java">import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class XlsxReader {
public static void main(String[] args) throws Exception {
new XlsxReader().readxml();
}
public void readxml() throws Exception {
InputStream input = ClassLoader.getSystemResourceAsStream( "sheet3.xml" );
BufferedReader reader = new BufferedReader( new InputStreamReader(input));
reader.readLine();
char [] cs = new char[1000];
int cnt = -1, total = 0;
while ((cnt = reader.read(cs, 0, cs. length )) != -1) {
total += cnt;
// 第一次提示报错位置为第二行第82450988列
if (total > 82450000 & total < 82451000 ) {
System. out .println( new String(cs, 0, cnt));
}
}
}
}
4、把打印出来的内容分析了一下,没有发现什么错误,可见office提示的错误不准确,再写个程序B检测一下语法(java),代码如下&