ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel.Range.set_Value causing "Exception from HRESULT: 0x800A03EC" (https://www.excelbanter.com/excel-programming/423547-excel-range-set_value-causing-exception-hresult-0x800a03ec.html)

OC Evan

Excel.Range.set_Value causing "Exception from HRESULT: 0x800A03EC"
 
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.xlWBATWorksh eet);

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.


All times are GMT +1. The time now is 01:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com