NPOI : how to read excel cell which having no header

Feb 25, 2014 at 6:31 AM
i am trying to extract TEXT from .xlsx excel file using NPOI.

below is the link of sample excel file:

Image

the function ExcelDocumentToText extract all the cell

but not the cell which contaion INR (cell F2)
    static void ExcelDocumentToText(string path = @"..\..\..\01.xlsx")
    {
        StringBuilder textOfExcelDocumnet = new StringBuilder();
        ISheet sheet = null; IRow headerRow = null; IEnumerator allRows = null;

        using (FileStream ExcelFile = new FileStream(path, FileMode.Open, FileAccess.Read))
            xlsReaderObject = new XSSFWorkbook(ExcelFile);

        for (int j = 0; j < xlsReaderObject.Count; j++)
        {
            sheet = xlsReaderObject.GetSheetAt(j);
            for (int p = 0; p < sheet.LastRowNum; p++)
            {
                headerRow = sheet.GetRow(p);
                if (headerRow != null)
                    break;
            }
            allRows = sheet.GetRowEnumerator();

            int colCount = headerRow.LastCellNum;

            while (allRows.MoveNext())
            {
                //IRow row = (HSSFRow)rows.Current;
                IRow row = (XSSFRow)allRows.Current;
                for (int i = 0; i < colCount; i++)
                {
                    ICell cell = row.GetCell(i);
                    if (cell != null)
                        textOfExcelDocumnet.AppendLine(cell.ToString());
                }
            }
            sheet = null; headerRow = null; allRows = null;
        }
        xlsReaderObject = null;

        Console.WriteLine(textOfExcelDocumnet.ToString());
    }
Could anyone please have some solution of this querry???
Coordinator
Mar 13, 2014 at 10:33 PM
You should try toxy. It's based on NPOI. You can download it from toxy.codeplex.com. It supports convert sheet/workbook to datatable/dataset.
Marked as answer by tonyqus on 4/12/2014 at 2:36 PM