This project has moved. For the latest updates, please go here.

Problems Finding named worksheet created by another process

Mar 5, 2012 at 7:03 PM
Edited Mar 5, 2012 at 7:25 PM

I am using SSIS to create my excel file. I can open the file even look at the unzipped excel zip file to look at the underlying xml content, but when i try and open up the work sheet by name, i can't find any data through code.

ExcelPackage excelPackage = new ExcelPackage(fileInfo);

ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1]; 

I then want to apply formatting and append new lines to the excel document.

   worksheet.InsertRow(1, 2);

   worksheet.Cells[1, 1].Value = "Report TEXT";
   worksheet.Cells[1, 1, 1, 7].Merge = true;
   worksheet.Cells[1, 1, 1, 7].Style.Font.Bold = true;
   worksheet.Cells[1, 1, 1, 7].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;

When i try to look at the excel obect in the locals window i can't ever find the xml i am expecting. Anybody else ran into this issue?

When i look at the value of the InnerXml the data sheet is empty.

<worksheet xmlns="" xmlns:r=""><dimension ref="A1:G137" /><sheetViews><sheetView tabSelected="1" workbookViewId="0" rightToLeft="false"><selection activeCell="C5" sqref="C5" /></sheetView></sheetViews><sheetFormatPr defaultRowHeight="15" /><sheetData /><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3" /><headerFooter /></worksheet>

But when i dig deeper into the underlaying object i can see that it is correctly pointing to xl/worksheet/sheet1.xml. Now when i unzip the package and view the resultsing sheet1.xml in a viewer the excel xml is as i expected it to be.


Mar 6, 2012 at 3:08 PM

Never mind, I figured out what i was doing wrong... This is still a great library for modifying excel. :-)

Must save back to the excelpackage to get the changes...