openxml spreadsheat save-as

前端 未结 6 1665
无人共我
无人共我 2020-12-03 14:28

I have an Excel 2007 spreadsheet that I edit with the OpenXML SDK 2. I remove some rows etc. I would like to know how to save that Spreadsheetdocument to another filename.

6条回答
  •  天命终不由人
    2020-12-03 15:04

    You could save that Spreadsheetdocument to another filename then open it to edit.

    string sourceFile = "C:\Users\***.xlsx";
    string destFile = "C:\Users\*****.xlsx";
    System.IO.File.Copy(sourceFile, destFile, true);
    using (SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Open(destFile, true))
    {
      //remove some rows etc
      //save workbookpart
    }
    

    References:How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)

提交回复
热议问题