[英]Do you have to save the Open XML document after working on it?
Sorry, here's a stupid question. 抱歉,这是一个愚蠢的问题。 I've been working on a document using the Open XML SDK and I don't see the changes I've made to it after I dispose off the
SpreadsheetDocument
object. 我一直在使用Open XML SDK处理文档,在丢弃
SpreadsheetDocument
对象后,看不到对它所做的更改。
using (var spreadsheet = SpreadsheetDocument.Open(file, true))
{
// do stuff to the document
}
// when I exit the program and open the workbook as an end-user
// I don't see any of the changes I made
I think I used to see the changes with examples I did before but I can't be so sure. 我想我曾经通过以前的示例来查看更改,但是我不确定。
Do you have to save the document after working on it to see the changes? 要查看更改,是否需要保存文档? I don't see such a method to save the document.
我看不到这种保存文档的方法。
Sorry, a little bit of searching revealed to me what I'd forgotten. 抱歉,一点点搜索向我揭示了我忘记的事情。 Apparently, you have to save the XML DOM you just updated.
显然,您必须保存刚更新的XML DOM。
Since I updated the WorksheetPart
, and the WorksheetPart
is of type OpenXmlPart
and its DOM is represented by the Worksheet
property of type Worksheet
, I had to do this: 因为我更新了
WorksheetPart
和WorksheetPart
类型是OpenXmlPart
和DOM由代表Worksheet
类型的属性Worksheet
,我不得不这样做:
using (var spreadsheet = SpreadsheetDocument.Open(file, true))
{
// do stuff to the document
// finally
worksheetPart.Worksheet.Save();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.