Click to See Complete Forum and Search --> : Response.Write(Excel WorkSheet) shows System._ComObject


jwu1023
March 21st, 2006, 06:07 PM
Dear all,

After I assinged the values to an in memory Excel worksheet, I liked to send it to the client side and let the user save it as an Excel file. The following is part of my code:

qxlws.Range((excelCol.data(1)) & CStr(1)).Value = dt.Tables(0).Columns(1).ColumnName
qxlws.Range((excelCol.data(1)) & CStr(2)).Value = dt.Tables(0).Columns(2).ColumnName

Response.ContentType = "application/vnd.ms-excel"
Response.Write(qxlws)
Response.End()

But when I opened the saved Excel file, it only shows "System._ComObject".

Anyone can help me with it is highly appreciated.

mcmcom
March 21st, 2006, 07:53 PM
you are in essence, writing the descriptor for the object qxlws in your output.

To Save the Excel File you should not write to using Response.write. The Excel Object actually has a save function. Look into the Excel object's "Save As" method.

hth,
mcm