A Repasky

A Repasky

  • NA
  • 231
  • 183.1k

Error with OpenXML

Jul 29 2011 10:09 AM
I am getting the following error after opening an Excel file that I just created with a C# program.

  <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <logFileName>error035480_01.xml</logFileName>
  <summary>Errors were detected in file 'X:\BatchOther\NYClaims\NYClaims_20110630.xlsx'</summary>
- <removedRecords summary="Following is a list of removed records:">
  <removedRecord>Removed Records: Cell information from /xl/worksheets/sheet.xml part</removedRecord>
  </removedRecords>
  </recoveryLog>

Sorry, when I paste it, the lines come with it.  Here is the snippet of code.  I only write out 1 header row and 10 data rows to test this.  I seems to all work and I get a successful execution, but when I open the Excel file it says that there were errors and removed the bad records.  I copied most of the code from and existing program, but wrote the following method to cut down on coding each cell.  Plus I have I am going to use this with other program and I had to make a method that would handle fields coming in from different SQL scripts.

      //-----------------------------------------------------------------------------------
      //Create Cell in spreadsheet
      public static void WriteCell(string sb, Row r, Cell c, int col, int row, int sv)
      {         PrintLog("sb=" + sb + "  r=" + r.ToString() + "  c=" + c.ToString() + "  col=" + col.ToString()
            + "  row=" + row.ToString() + "  sv=" + sv.ToString());


         if (sv == 1)
            c.DataType = CellValues.String;
         else
            c.DataType = CellValues.Number;






        c.CellReference = cols[col] + row.ToString();
         c.CellValue = new CellValue(sb);
         r.Append(c);

      }



I have searched online, but I am not finding a solution. I think it has to do with the message:



Cell information from /xl/worksheets/sheet.xml part








But I do not know how to fix it. I do not know if I put this in the correct forum!




Any help would be greatly appreciated. If anyone needs something else let me know.




arep










Answers (2)