I would like to deserialize all the data from the excel file to list.
I am using this code
class ExcelImport
{
Workbook workBook;
SharedStringTable sharedStrings;
IEnumerable<Sheet> workSheets;
WorksheetPart custSheet;
WorksheetPart orderSheet;
string FilePath;
ExcelStorage provider;
Stiker[] ans;
List<Stiker> StikerList;
public ExcelImport(string fp)
{
FilePath = fp;
}
public List<Stiker> dothejob()
{
using (SpreadsheetDocument document =
SpreadsheetDocument.Open(FilePath, true))
{
StikerList= new List<Stiker>();
workBook = document.WorkbookPart.Workbook;
workSheets = workBook.Descendants<Sheet>();
sharedStrings = document.WorkbookPart.SharedStringTablePart.SharedStringTable;
StikerList = Stiker.LoadStiker(custSheet.Worksheet, sharedStrings);
return StikerList;
}
}
But from some reson I get exception in the line:sharedStrings =
document.WorkbookPart.SharedStringTablePart.SharedStringTable;
that "Object reference not set to an instance of an object.".
After the above saggestion found that the
if (sharedStringTablePart == null)
{
// report a problem
}
rerurn null
Any idea?