Random corruption of import data using ExportDataTableAsString


#1

Attached is a spreadsheet containing a worksheet that gets imported into my asp.net application. The data is uploaded with a file control and then the stream is imported into an excel object so that I can manipulate it. The data may contain errors with the field value data types so it has to be imported using the ExportDataTableAsString. I then add a couple of columns to hold error indicators and messages. Running this code on my local machine (XP with version 3.4.2.0) with hte same data file results in random corrupt data appearing (see attached sheets). Interestingly, it does not seem to happen in the StudentName column for the few times i have tried it. Below is the code i am using to get the data from my sheet. exportdatatable is commented out. When using that and perfect data, the results worked every time so the problem seems to be with ExportDataTableAsString rather than any outside influences such as stream corruption.
As an aside, it would be nice to have a function for DoesWorksheetExist which is not case sensitive as well as one for retreiving a worksheet which is also not case sensitive as i am having to run through all the sheets uppercasing them till i find the sheet i want…

Please help!

Thanks

Jon


///


/// Create a datatable of all the rows in the worksheet starting at the
/// top left (defaults to 0,0) and including the headings. This means we
/// can then just save like a normal data all the columns we need without
/// having to do mass manipulation of data.
///

private bool CollectData()
{
bool blnSuccess=true;

// Take the basic data from our sheet
Worksheet wksSheet =GetWorkSheet(_strWorksheetName);

_dtbSheetData = wksSheet.Cells.ExportDataTableAsString(_intFirstRow,_bytFirstCol, wksSheet.Cells.MaxDataRow+1, wksSheet.Cells.MaxDataColumn+1,true);
//_dtbSheetData = wksSheet.Cells.ExportDataTable(_intFirstRow,_bytFirstCol, wksSheet.Cells.MaxDataRow+1, wksSheet.Cells.MaxDataColumn+1,true);

// Now add a couple of extra columns that we can use to give feedback about the rows
if (_dtbSheetData.Rows.Count >0 )
{
DataColumn colBoolean = new DataColumn(“HasError”);
colBoolean.DataType = System.Type.GetType(“System.Boolean”);
_dtbSheetData.Columns.Add(colBoolean);

DataColumn colString = new DataColumn(“ErrorReason”);
colString.DataType = System.Type.GetType(“System.String”);
_dtbSheetData.Columns.Add(colString);

}
else
{
AddErrorMessage(0, “No rows to process”);
blnSuccess= false;
}

// Final check to make sure that we have all the rows we are expecting
if (blnSuccess)
blnSuccess=CheckRowsExist();

return blnSuccess;
}


#2

It’s an evaluation limitation. Please check http://www.aspose.com/Wiki/default.aspx/Aspose.Excel/LicensingComponent.html for reference.


#3

Brilliant! such a relief to know it’s ok. Perhaps to avoid confusion with other people some sort of comment could be added or a link shown to list main evaluation limitations on the extra sheet that you add automatically…

Thanks

Jon


#4

Thanks for your suggestion. I will add this comment in the extra worksheet.


#5

Nice to see I have helped contribute to the new release… just a couple of tiny points - “added” has two d’s at the end and IMHO the message tone looks a bit threatening with so many WARNINGs…

:slight_smile: