Hi,
I currently have an Ultragrid that makes use of the ultragrid excel exporter to export the contents of the grid to an excel document.
This works fine but I now have a requirement to export the grid data to a new worksheet in an existing XLS document in a particular directory.
Does anyone know if this is possible?
Thanks,
Mark.
I've solved the problem with this (simplified) example code below. I actually want to overwrite an existing worksheet:
DEFINE VARIABLE class1 AS CLASS Infragistics.Excel.Workbook.
DEFINE VARIABLE ws AS Infragistics.Excel.Worksheet.
DEFINE VARIABLE wsExporter AS Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE lvcFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE lvcWorksheetName AS CHARACTER NO-UNDO.
ASSIGN
lvcFileName = "C:\temp\2013-01-30-32118547.XLS"
lvcWorksheetName = "MyNewWorkSheet".
class1 = Infragistics.Excel.Workbook:LOAD(lvcFileName).
class1:Worksheets:Add(lvcWorksheetName).
_loop:
DO i = 1 TO Class1:Worksheets:Count:
IF Class1:Worksheets[i]:Name = lvcWorksheetName THEN
DO:
wsExporter = NEW Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter().
ws = Class1:Worksheets[lvcWorksheetName].
wsExporter:Export(ultraGrid1, ws).
class1:SAVE(lvcFileName).
LEAVE _loop.
END.
END.