打开 XML:我们发现 'myfile.xlsx' 中的某些内容存在问题

Open XML: We found a problem with some content in 'myfile.xlsx'

我正在使用 Open XML SDK 创建一个 Excel 文件。

Worksheet newWs = new Worksheet()
{
    MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" }
};

当我如下添加一个SheetViews实例时,

SheetViews sheetViews = new SheetViews();
SheetView sheetView = new SheetView();
Selection selection = new Selection() { ActiveCell = "B1" };
sheetView.Append(selection);
sheetViews.Append(sheetView);
newWs.Append(sheetViews);

我收到如下所示的错误(而且 ActiveCell 不工作):

We found a problem with some content in 'myfile.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.

这是 excel xml 元素的排序问题。

我在应用样式后应用了工作表视图。

哪个打开xml不喜欢。

所以我通过使用 XML SDK 生产力工具了解了这一点。这有助于做出正确的顺序。