Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Microsoft.Office.Interop.Excel.Application
Hi All,
I am using Microsoft.Office.Interop.Excel.Application COM to create a Excel spreadsheet, and write the value (not from any dataset) into that spreadsheet, and then StreamWrite to the disk. For some reason, the following code is not working. This is the declaration of ws: Microsoft.Office.Interop.Excel.Worksheet ws =(Microsoft.Office.Interop.Excel.Worksheet)wb.Work sheets[1]; ws.Cells[1, 1] = "CardNo"; ws.Cells[1, 2] = "PharmacyName"; ws.Cells[1, 3] = "CostPerCard"; sw.Writer(ws.Cells[1, 1]); sw.Writer(ws.Cells[1, 2]); sw.Writer(ws.Cells[1, 3]); I thought this code will write to the spreadsheet like this: A | B | C ----------------------------------------------- CardNo | PharmacyName | CostPerCard but, it wrote to spreasheet like this, all them just in column A: A ----------------------------------------------- System.__ComObjectSystem.__ComObjectSystem.__ComOb jectH40655 I have been spent quite lots of time on it, but still couldn't work it out. Thanks heaps |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Microsoft.Office.Interop.Excel.Application
Hi
I worked it out. lol I can't use the StreamWriter to write the value into spreadsheet and save it, i have to use Excel.Workbook.SaveAs() method to save the spreadsheet. Thanks for your help anyway. Andie "Andie" wrote: Hi All, I am using Microsoft.Office.Interop.Excel.Application COM to create a Excel spreadsheet, and write the value (not from any dataset) into that spreadsheet, and then StreamWrite to the disk. For some reason, the following code is not working. This is the declaration of ws: Microsoft.Office.Interop.Excel.Worksheet ws =(Microsoft.Office.Interop.Excel.Worksheet)wb.Work sheets[1]; ws.Cells[1, 1] = "CardNo"; ws.Cells[1, 2] = "PharmacyName"; ws.Cells[1, 3] = "CostPerCard"; sw.Writer(ws.Cells[1, 1]); sw.Writer(ws.Cells[1, 2]); sw.Writer(ws.Cells[1, 3]); I thought this code will write to the spreadsheet like this: A | B | C ----------------------------------------------- CardNo | PharmacyName | CostPerCard but, it wrote to spreasheet like this, all them just in column A: A ----------------------------------------------- System.__ComObjectSystem.__ComObjectSystem.__ComOb jectH40655 I have been spent quite lots of time on it, but still couldn't work it out. Thanks heaps |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Microsoft.Office.Interop.Excel when exporting from another program | Excel Discussion (Misc queries) | |||
Microsoft.Office.Interop.Excel Texttocolumns C# | Excel Programming | |||
Where can I find Microsoft.Office.Interop.Excel.dll? | Excel Programming | |||
COMException With Microsoft.Office.Interop.Excel | Excel Programming | |||
Microsoft.Office.Interop.Excel SaveAs error when clicking no or ca | Excel Programming |