title: ClosedXML writing to all sheets in Excel
body: <p>I've been working with ClosedXML for the past 24 hours, I feel as if I've gotten everything out of it I need except for one bug. I have an existing workbook that has 3 sheets in it currently. Similar data will be on each sheet but it will be different values. I've attached my pseudo code below (Specific variable names have been changed to protect the innocent).</p>
  
  <p>The code below is inside a foreach loop as I'm looping thru a large set of SQL tables. The problem is, ClosedXML or something I have done is writing the same data to all sheets and overwriting the sheets in front and behind it. I feel perhaps I've done something obvious but I've been staring at the same code for awhile and can no longer see the glaring error. Any help would be appreciated!</p>
  
  <pre><code>  //Workbook = new workbook and filepath are initialized outside of the loop
                      var worksheet = workbook.Worksheet(1);
  
                  //This is used to help me identify what column it is in, it references an array of alphabet characters later
                  int column = 0;
  
                  if(loopCt &lt;= 2)
                  {
                      worksheet.Cell("A1").Value = "Identifier";
                      worksheet.Cell("B1").Value = "XYZ Day 1";
                      worksheet.Cell("C1").Value = "XYZ Day 2";
                      worksheet.Cell("D1").Value = "XYZ Day 3";
                      worksheet.Cell("E1").Value = "XYZ Day 4";
                      worksheet.Cell("F1").Value = "XYZ Day 5";
                      worksheet.Cell("G1").Value = "XYZ Day 6";
                      worksheet.Cell("H1").Value = "XYZ Day 7";
                      worksheet.Cell("I1").Value = "XYZ Day 8";
                      worksheet.Cell("J1").Value = "XYZ Day 9";
                      worksheet.Cell("K1").Value = "XYZ Day 10";
                      worksheet.Cell("L1").Value = "XYZ Weekly Total";
                  }
  
                  worksheet.Cell($"A{loopCt}").Value = item.identifier;
  
                  for (int i = 0; i &lt; XYZDaily.Count(); i++)
                  {
                      column += 1;
                      worksheet.Cell($"{alphabet[column]}{loopCt}").Value = XYZDaily[i];
  
                  }
  
                  worksheet.Cell($"L{loopCt}").Value = XYZWeek;
  
                  workbook.Save();
  
                  //QRS Export
  
                  var worksheetQRS = workbook.Worksheet(2);
                  int columnQRS = 0;
  
                  if (QRSCt &lt;= 2)
                  {
                      worksheetQRS.Cell("A1").Value = "Identifier";
                      worksheetQRS.Cell("B1").Value = "QRS Day 1";
                      worksheetQRS.Cell("C1").Value = "QRS Day 2";
                      worksheetQRS.Cell("D1").Value = "QRS Day 3";
                      worksheetQRS.Cell("E1").Value = "QRS Day 4";
                      worksheetQRS.Cell("F1").Value = "QRS Day 5";
                      worksheetQRS.Cell("G1").Value = "QRS Day 6";
                      worksheetQRS.Cell("H1").Value = "QRS Day 7";
                      worksheetQRS.Cell("I1").Value = "QRS Day 8";
                      worksheetQRS.Cell("J1").Value = "QRS Day 9";
                      worksheetQRS.Cell("K1").Value = "QRS Day 10";
                      worksheetQRS.Cell("L1").Value = "QRS Weekly Total Test";
  
                  }
  
                  worksheetQRS.Cell($"A{loopCt}").Value = item.Identifier;
  
                  for (int i = 0; i &lt; QRSDaily.Count(); i++)
                  {
                      columnQRS += 1;
                      worksheetQRS.Cell($"{alphabet[columnQRS]}{loopCt}").Value = QRSDaily[i];
  
                  }
  
                  worksheetQRS.Cell($"L{loopCt}").Value = QRSWeek;
  
  
                  workbook.Save();
  </code></pre>
  
  <p>TL:DR; 
  Writing data to an existing spreadsheet with multiple sheets, 
  Written inside a foreach loop</p>
  
  <p>Problem: I'm attempting to target one sheet at a time, write data, move on to the next sheet and write data, but its writing the same data to all sheets within the workbook and I cant find anything in the documentation about this particular scenario. </p>
  
  <p>Thanks for reading, </p>