I have an excel document that is supposed to be parsed using the following block of code:
var handler = new ExcelHandler(byteStream);
var currentExcelDocument = handler.CurrentDocument;
//now if the document is null
if (currentExcelDocument == null)
{
throw new Exception("Excel file handle missing");
}
var wokrbookpart = currentExcelDocument.WorkbookPart;
//get a list of all the sheets
string text = String.Empty;
var sheets = wokrbookpart.Workbook.Descendants<Sheet>().ToList();
foreach (var sh in sheets)
{
//now we have the sheets but the data must be in the first sheet
var themainsheet = sh;
if (themainsheet == null)
throw new ArgumentException("sheetName");
//now we need a reference to the worksheetpart
var worksheetpart = (WorksheetPart)wokrbookpart.GetPartById(themainsheet.Id);
SheetData data = worksheetpart.Worksheet.Elements<SheetData>().First();
//now we have a reference to the cells that contain data we start passing the data
foreach (Row r in data.Elements<Row>())
{
//we get the cells in the row
var cells = r.Elements<Cell>().ToList();
foreach (var i in cells)
{
text += i.CellValue.InnerText;
}
}
}
return text;
the excel file is uploaded via a fileupload control in asp.net and the stream is passed into the above block of code.
All is well though but then when i display the resulting text in the label, I see that the result of reading the cell values is displayed as a sequence of numbers even though i am hindred percent sure that there are no numbers in the data
Please what could i be doing wrong??