I am astonished, we cannot find a simple way to import a workbook or a worksheet into a wingrid. we are working with 2007.3 but we cannot find a way to simple import as we can easily export to excel.
Is it not implemented? do we have to manually import the worksheet data cell by cell???
please, advise
There is nothing built-in to the grid to do this. This is really not the grid's purview. The grid has no way to interpret an Excel sheet as data. What you would need to do is load the data from your Excel sheet into some data source that the grid can use, like a DataSet, IList, or IBindingList.
well, that is not what you advertised!
Please, check your 2007.3 brochure, it explicitely says:
http://download.infragistics.com/marketing/NetAdvantage/NET/NA73Brochure.pdf
"Our grids provide developers with the power and flexibility necessary to create compelling data display and entry applications in both Windows Forms and Web environments."
Additionally, I remember some pics in the what's new documents with nice arrows telling that it was possible to import excel into the grid capturing everything, not only the data.
What shall we do now? do the work you claimed was in the release or you kindly send us a patch with it built in?
This is not serious at all!
Hi Duetto,
The Infragistics.Excel library has the capability to export and import data to and from Excel. The WinGridExcelExporter component that exports the WinGrid data to Excel w/ a single line of code can do so because we know that the data in the grid is a set structure. With Excel being a cell based grid that contain multiple tables (or data sets), it would make it difficult for us to assume that we could get a Worksheet into a DataSet and then into the WinGrid.
That being said, we have the whole Infragistics.Excel API that let's you manipulate Workbooks, Sheets and Cells. I posted a sample here that show the import and export capability in code:
http://download.infragistics.com/users/samplecode/excelio.zip
If you have any ideas on how we could do an automagic import of the data from a spreadsheet and that it would make sense in the WinGrid, let me know what you think.
Thanks
Jason
I am a little frustrated with this same topic. I understand the complexity of manipulating excel, but I would think you (Infragistics) could invest more effort into handling simple scenarios.
For example, I need to dump a grid out to excel, let the user modify the data, and then reimport the data into the grid; the structure will not change. Could you not create an API around importing data from a known excel structure? In this case it is known because your API's generated the export.
Hi,
If I understand correctly, what you are asking is exactly what this sample does:
It uses our Excel library API to read data to or from Excel.
Is there something that is missing that would make this easier?
Thanks for any feedback,
Hi Nicloas,
I took a look at the sample and it looks like this sample is written to just read in any Excel data with no notion of what the resulting data structure should be. Excel doesn't really have any notion of a data type like a DataTable has. So there's no way for a generic sample like this to interpret dates as dates, since Excel just stores dates as doubles.
If you know what the structure of your data should be, then you could create a DataTable with columns that have the appropriate data types and then when you read in the Excel data, you could convert the Excel values into the appropriate type as you go.
For dates, you would use the Infragistics.Excel.CalcEngine.ExcelCalcValue.ExcelDateToDateTime method to convert the value from a double into a DateTime.
Jason, i already test your example, and it work fine but when I receive dates and double values it doesn't work. They are formated to integer!
I looked inside object "cell", but there isn't any properties to resolve it.
Please help with this error.
Thanks!
Nicolas
Yes, it would be much easier if your object model had an API where I could supply a dataset and an XLS file and not have to write all of this iteration garbage.
If I can tell you the structure of how the data in the import file is going to be, then why should I have to implement code to iterate through workbook, worksheets, cells, and rows to create a dataset?
I just had different expectations when reading how the ultraGrid supports excel import, especially since your export API is a 1 liner. This would be like .NET touting how easy it is to work with POP3, when all they have done is abstracted the network communications and none of the MIME parsing.