D
David
I have a Windows forms application that features a DataGridView. I want to
give the users an option to save that data to an Excel spreadsheet file as a
..xls.
Is there an obvious way to do this that I am missing?
I am currently using the Microsoft.Office.Interop namespace to open Excel
and create the spreadsheet. That works, and it isn't bad, but there are a
couple of downsides. First, you have to launch Excel, which means that Excel
has to be installed on the user's PC, and that might not always be the case.
Second, it was kind of difficult to convince Excel to stop running after I
opened it. (Relasing com objects and such, forcing a garbage collection,
etc.) It didn't seem very "clean".
The data in the datagridview is not data that came from a dataset. I could
force it into a datatable, and then connect to the Excel file as if it were a
database, and probably clear the existing contents and upload new data, but
that also seems to have problems. I don't know if that could work on a file
that didn't already exist.
All I really want is to create a file, without resorting to opening Excel
itself. I want to give this to a user so he can collect data from someplace,
package it as an Excel file, and send it to me. So, a minimum of fuss would
be ideal. I just wondered if there was some "easy" way to do this that I was
overlooking.
give the users an option to save that data to an Excel spreadsheet file as a
..xls.
Is there an obvious way to do this that I am missing?
I am currently using the Microsoft.Office.Interop namespace to open Excel
and create the spreadsheet. That works, and it isn't bad, but there are a
couple of downsides. First, you have to launch Excel, which means that Excel
has to be installed on the user's PC, and that might not always be the case.
Second, it was kind of difficult to convince Excel to stop running after I
opened it. (Relasing com objects and such, forcing a garbage collection,
etc.) It didn't seem very "clean".
The data in the datagridview is not data that came from a dataset. I could
force it into a datatable, and then connect to the Excel file as if it were a
database, and probably clear the existing contents and upload new data, but
that also seems to have problems. I don't know if that could work on a file
that didn't already exist.
All I really want is to create a file, without resorting to opening Excel
itself. I want to give this to a user so he can collect data from someplace,
package it as an Excel file, and send it to me. So, a minimum of fuss would
be ideal. I just wondered if there was some "easy" way to do this that I was
overlooking.