Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1225
Loading a Excel File into UltraGrid
posted

Hi friends, I'm trying to load an file xls into my grid but any cells are not recognized, I'm obtaining Nothing, Please I need you help, I'm using this code:

objExcel = Infragistics.Excel.Workbook.Load(Path.Text, packageFactoryExcel, False)

objExcel.Worksheets(strNombreHoja).Workbook.SuspendCalculations()

--------------

To obtain the cell value I'm using this:

strFieldsValue = objExcel.Worksheets(strSheetName).GetCell(strCell).Value.ToString()

The cell in my Excel file have value but Infragistics says Nothing,

Please, any idea?

Thanks a lot, God bless you.

 

  • 4618
    Suggested Answer
    posted

    Hi ErosDark,

    Davide is correct in that the UltraGrid with the aid of the UltraGridExcelExporter is only currently intended to support the export of Excel documents and that there is currently no supported functionality for importing Excel documents.

    That isn’t to say that it cannot be done, however, but it would require some custom implementation. One possible approach might involve writing the Excel worksheet data to a DataTable and then binding the UltraGrid to the resulting table.

    There are several online resources available that document possible approaches for writing an Excel worksheet to a DataTable or similar construct, links to which I have provided below for reference.

    Note: These external resources are not maintained or endorsed by Infragistics, but I believe you may find the information provided useful.

    Importing Excel file into dataset:
    http://www.codeproject.com/Articles/32370/Import-Excel-File-to-DataSet
    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/b080ec5a-7255-49a4-93f2-a29b943a3903/

    Note: I have also constructed and attached a basic sample which demonstrates one possible approach for “importing” cell data from an Excel worksheet into a DataTable which is then bound to an UltraGrid to display its data; remember that this behavior is not supported by the control, but perhaps you may find this information useful.

    Please find the sample attached.

    I have also submitted product idea PI12070071, to have Excel Import behavior considered for integration into a future release with the UltraGrid.

    If you would like to follow up on your product idea at a later point, you may contact Developer Support management via email.  Please include the reference number of your product idea in the subject and body of your email message.  You can reach Developer Support management through the following email address:  dsmanager@infragistics.com

    If you have any further questions that I may assist you with, please let me know.

    Sincerely,
    Chris K
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com/support

    LoadExcelFileToGrid95750.zip
  • 1158
    Offline posted

    Hi ErosDark,

    normally I've accessed to cells via Row e Column indexes and it works fine, like:
    (CellExportedEventArgs e )
    e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].Value;


    Have you tried with: .GetCell("aa",CellReferenceMode.R1C1) or with CellReferenceMode.A1 ??

    My experience on Infragistics-Excel it's only for exporting data in UltraGrid versus an Excel with right data in cell and right formatting.

    U welcome,
    God bless you.