title: The process cannot access the file because it is being used by another process using spreadsheet document
body: <p>Please help me to solve the problem, when i save the excel file throw this error i convert the excel file to zip file. </p>
  
  <pre><code>zip.Save(@"" + root + "/" + "" + userid + ".zip");
  </code></pre>
  
  <p>the process cannot access the file because it is being used by another process 
  my code is below</p>
  
  <pre><code>  using (SpreadsheetDocument document = SpreadsheetDocument.Create(excelFilename, SpreadsheetDocumentType.Workbook))
          {
               WriteExcelFile(ds, document);
          }
  
  private static void WriteExcelFile(DataSet ds, SpreadsheetDocument spreadsheet)
  {
      spreadsheet.AddWorkbookPart();
      spreadsheet.WorkbookPart.Workbook = new DocumentFormat.OpenXml.Spreadsheet.Workbook();
  
      spreadsheet.WorkbookPart.Workbook.Append(new BookViews(new WorkbookView()));
  
      //  If we don't add a "WorkbookStylesPart", OLEDB will refuse to connect to this .xlsx file !
      WorkbookStylesPart workbookStylesPart = spreadsheet.WorkbookPart.AddNewPart&lt;WorkbookStylesPart&gt;("rIdStyles");
      Stylesheet stylesheet = new Stylesheet();
      workbookStylesPart.Stylesheet = stylesheet;
  
      //  Loop through each of the DataTables in our DataSet, and create a new Excel Worksheet for each.
      uint worksheetNumber = 1;
      foreach (DataTable dt in ds.Tables)
      {
          //  For each worksheet you want to create
          string workSheetID = "rId" + worksheetNumber.ToString();
          string worksheetName = dt.TableName;
  
          WorksheetPart newWorksheetPart = spreadsheet.WorkbookPart.AddNewPart&lt;WorksheetPart&gt;();
          newWorksheetPart.Worksheet = new DocumentFormat.OpenXml.Spreadsheet.Worksheet();
  
          // create sheet data
          newWorksheetPart.Worksheet.AppendChild(new DocumentFormat.OpenXml.Spreadsheet.SheetData());
  
          // save worksheet
          WriteDataTableToExcelWorksheet(dt, newWorksheetPart);
          newWorksheetPart.Worksheet.Save();
  
          // create the worksheet to workbook relation
          if (worksheetNumber == 1)
              spreadsheet.WorkbookPart.Workbook.AppendChild(new DocumentFormat.OpenXml.Spreadsheet.Sheets());
  
          spreadsheet.WorkbookPart.Workbook.GetFirstChild&lt;DocumentFormat.OpenXml.Spreadsheet.Sheets&gt;().AppendChild(new DocumentFormat.OpenXml.Spreadsheet.Sheet()
          {
              Id = spreadsheet.WorkbookPart.GetIdOfPart(newWorksheetPart),
              SheetId = (uint)worksheetNumber,
              Name = dt.TableName
          });
  
          worksheetNumber++;
      }
  
      spreadsheet.WorkbookPart.Workbook.Save();
  }
  </code></pre>