私は同じ問題を抱えていましたが、これに対処するコードはMicrosoft's Custom XML Partsです。 (コード内のコメントにすべての必要な説明があります)。上記で使用xlworkbook
オブジェクトについて
//Deletes all the previously added parts and adds a new part
//containing the string argument which has to be in XML format.
public void addCustomXMLPart(string test)
{
IEnumerator e = Xlworkbook.CustomXMLParts.GetEnumerator();
e.Reset();
CustomXMLPart p;
//The !p.BuiltIn is because before our customXMLPart there are some
// Excel BuiltIns of them and if we try to delete them we will get an exception.
while (e.MoveNext())
{
p = (CustomXMLPart)e.Current;
if (p != null && !p.BuiltIn)
p.Delete();
}
Xlworkbook.CustomXMLParts.Add(test, Type.Missing);
}
:
using Excel = Microsoft.Office.Interop.Excel;
Excel.Workbook XlWorkbook = (Excel.Workbook)
(Excel.Application)Marshal.GetActiveObject("Excel.Application")).ActiveWorkbook;
私は、埋め込まれたOLEオブジェクトを使用する必要がありますか?またはカスタム部分ですか? – user542393
このxmlをファイルに保存する目的は何ですか? –