使用演示文稿(PPTX 文件)创建代码打开时出现错误。我正在使用的代码如下:
public static void UpdatePPT()
{
const string presentationmlNamespace = "http://schemas.openxmlformats.org/presentationml/2006/main";
const string drawingmlNamespace = "http://schemas.openxmlformats.org/drawingml/2006/main";
string fileName = Server.MapPath("~/PPT1.pptx"); //path of pptx file
using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))
{
} // Using pptPackage
}
我得到的错误是:
"The document cannot be opened because there is an invalid part with an unexpected content type.
[Part Uri=/ppt/printerSettings/printerSettings1.bin],
[Content Type=application/vnd.openxmlformats-officedocument.presentationml.printerSettings],
[Expected Content Type=application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings]."
错误发生在using (PresentationDocument pptPackage = PresentationDocument.Open(fileName, true))
代码适用于许多 PPTX 文件。但它在某些文件上抛出了这个错误。我找不到任何解决方案。谢谢你的帮助。