Read Excel from Excel Pack

Nov 26, 2013 at 1:51 AM
Edited Nov 27, 2013 at 5:21 AM
I have a class which read excel file by ExcelPackage (The class name is Excel Reader). When you don't use 'Delete' combine with 'Clear content' menu of office , excel reader is right.

But, when you try to 'Delete' command at column lists in Excel tool, and after that use 'Clear content' command at Row lists in Excel tool. Excel reader is incorrect. I have used the office 2007 professional.

my code block maybe wrong. But I can't understand what wrong it is ? So, I capture some picture from my desktop , upload my code block and attack my error excel file into Mediafire. And I Hope that somebody in the great Epplus team may help me :). Your product works so well, but May that problem be an issue of your project ? Please help me, I stuck with this problem 2 days ago :(.

This is a block code
int SheetColumnsCount = item.Dimension.End.Column;// Find End Column
int SheetRowCount = item.Dimension.End.Row;// Find End Row

if (
    SheetColumnsCount > 0
    &&
    SheetRowCount > 0
   )
{
    for (int indexRows = 1; indexRows <=SheetRowCount; indexRows++)
    {
        DataRow row = SheetItemInfomation.Data.NewRow();//Create new row

        for (int indexCols = 1; indexCols <=SheetColumnsCount; indexCols++)
        {
            if (item.Cells[indexRows, indexCols].Value != null)//if value is not null (it mean you didn't use the clear content menu)
                row["Cols_" + ((int)(indexCols-1)).ToString()] = item.Cells[indexRows, indexCols].Value;
            else//It mean that the value of row is empty because of the clear content are used.
                row["Cols_" + ((int)(indexCols - 1)).ToString()] = "";
        }

        SheetItemInfomation.Data.Rows.Add(row);
    }

    SheetItemInfomation.RemoveBlankColumns(TrimedPosition);
    SheetItemInfomation.RemoveBlankRows();

    Sheets.Add(SheetItemInfomation);
    ToTalSheetCount++;
}
This is a link of error file
http://www.mediafire.com/view/ddc48vcqc83hcfx/error.xlsx

And this is a serial of demonstration steps to create error :
Delete column
Image

Clear content of row
Image

Actual data in excel file :
Image

Reader 's Data in code :
Image
Nov 27, 2013 at 9:48 AM
Edited Dec 4, 2013 at 1:36 AM
Help me please, my project are running, and few users sometime have complex actions in their excel files. For example , an academic user have grade information files from teachers. And the users must combine all files together to create a final grade information file.

In their process, they must copy, paste, delete and sometime clear the content of their excel files (because of their mistake for example). And this issue accompany with the complicate their actions. After that, the issue make a reading Data is incorrect.

And my program always check the conditional of each cells. Because of above issue, my program will reject excel file :( (in each different context the program will reject by different conditional -it depend on error's reading data ).

I can't explain for them :( . So please help me.
Developer
Nov 29, 2013 at 4:32 AM
Hi,

Sorry about your problem. However, I am not sure if I understand it. Do you open the file in Excel, remove some data, save and close the file, then open it with EPPlus? And when you open it with EPPlus you find things that is not there if you open it with Excel?

If I find the time to look deeper into this - please describe how I can recreate your problem.
Nov 30, 2013 at 1:59 AM
Edited Nov 30, 2013 at 2:08 AM
Thank for reply Swmal.

swmal wrote:
Sorry about your problem. However, I am not sure if I understand it. Do you open the file in Excel, remove some data, save and close the file, then open it with EPPlus? And when you open it with EPPlus you find things that is not there if you open it with Excel?
You completely understand my problem. And I will create an video to demo that how to create my problem (all steps' detail ).

After that I will upload into youtube website and embed video in this forum for you to get further more information.

Thank alot once more times.