?
=?iso-8859-1?Q?Michel_M=FCller?=
Is there a faster way to access cells in excel with c#?
Here is a codesample how i access the cells in excel to get the values.
I did the same before with vb and it was 100-time faster than now! As a found out the most expensive functions are the following two lines.
tempRange = (Excel.Range)dataRange.Cells[z,i];
testValue = tempRange.get_Value(Type.Missing);
Here is the for loop through the excelsheet.
for(int z=intStartRow; z<intRowCount+1; z++ )
{ intLineNumber = z;
newRow = rteTable.NewRow();
for(int i=1; i<intColumnCount+1; i++ )
{ testValue = "dd";
// //testValue = ((Excel.Range)dataRange.Cells[z,i]).get_Value(Type.Missing);
tempRange = (Excel.Range)dataRange.Cells[z,i];
testValue = tempRange.get_Value(Type.Missing);
if(testValue != null)
{
theValues = GetPreparedString(testValue.ToString());
}
else
{
theValues = "";
}
//Fill the Columns
newRow[i-1] = theValues;
}
Thank's for ideas.
Michel
Here is a codesample how i access the cells in excel to get the values.
I did the same before with vb and it was 100-time faster than now! As a found out the most expensive functions are the following two lines.
tempRange = (Excel.Range)dataRange.Cells[z,i];
testValue = tempRange.get_Value(Type.Missing);
Here is the for loop through the excelsheet.
for(int z=intStartRow; z<intRowCount+1; z++ )
{ intLineNumber = z;
newRow = rteTable.NewRow();
for(int i=1; i<intColumnCount+1; i++ )
{ testValue = "dd";
// //testValue = ((Excel.Range)dataRange.Cells[z,i]).get_Value(Type.Missing);
tempRange = (Excel.Range)dataRange.Cells[z,i];
testValue = tempRange.get_Value(Type.Missing);
if(testValue != null)
{
theValues = GetPreparedString(testValue.ToString());
}
else
{
theValues = "";
}
//Fill the Columns
newRow[i-1] = theValues;
}
Thank's for ideas.
Michel