Excel.Range.set_Value causing "Exception from HRESULT: 0x800A03EC"

O

OC Evan

I'm writing an app to take an XML doc and turn it into a spreadsheet. I've
got it working with one section of the XML, but am getting "Exception from
HRESULT: 0x800A03EC" as another section is being inserted. The process is to
take the XML, convert it to a text file, convert the text to an array, and
insert the array as a dataset:

Excel.Application tds = new Excel.Application();
Excel.Workbooks tdsWorkBooks = (Excel.Workbooks)tds.Workbooks;
Excel.Workbook tdsWorkBook =
tds.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);

using (StreamWriter sw = new StreamWriter(filePath))
{
//Create the text file
}

Excel.Sheets tdsSheets = tdsWorkBook.Sheets;
Excel.Worksheet tdsWorkSheet = (Excel.Worksheet)tdsSheets.Add(tdsSheets[1],
Type.Missing, Type.Missing, Type.Missing);
object[,] tdsData = new Object[rows, 7];

//Convert the text to an array
using (StreamReader sr = new StreamReader(filePath))
{
int r = 0;
while ((tdsBuildArray = sr.ReadLine()) != null && r < rows)
{
string[] idArray = tdsBuildArray.Split("|".ToCharArray());
tdsData[r, 0] = idArray[0];
tdsData[r, 1] = idArray[1];
tdsData[r, 2] = idArray[2];
tdsData[r, 3] = idArray[3];
tdsData[r, 4] = idArray[4];
tdsData[r, 5] = idArray[5];
tdsData[r, 6] = idArray[6];
r++;
}
}
string iRange = "G" + rows.ToString();

//Insert the array as a dataset. This is where the break occurs
Excel.Range tdsRange = tdsWorkSheet.get_Range("A1", iRange);
tdsRange.set_Value(Type.Missing, tdsData);
tdsWorkSheet.Name = "Edit Specifications";
tdsWorkSheet = null;
tds.Quit();


I would appreciate any suggestions as to how to correct this issue. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top