Hello,
I am trying to edit an Excel file (.xlsx) that is located on a shared folder. This Excel workbook has 2 worksheets inside it. Sheet1 has some raw data in table form, while Sheet2 has a chart that uses the data from Sheet1.
I need to open the file and modify only Sheet1 by overwriting its content with the content from an internal table. I have tried the following methods:
FM 'MS_EXCEL_OLE_STANDARD_DAT'
This FM doesn`t let me edit an XLS file, it will only create a new one (or completely overwrite an existing one) with only one sheet with the data inside. This method will also automatically launch the Excel application.
FM GUI_DOWNLOAD
Pretty much the same reasons as the previous option.
Class cl_xlsx_document
I have tried the following code
lv_file_data = cl_openxml_helper=>load_local_file( 'C:\export.xlsx' ).
lo_package = cl_xlsx_document=>load_document( iv_data = lv_file_data ).
lo_parts = lo_package->get_parts( ).
lo_part = lo_parts->get_part( 2 ).
lo_parts = lo_part->get_parts( ).
lo_part = lo_parts->get_part( 2 ).
lv_uri = lo_part->get_uri( )->get_uri( ).
lo_xml_part_uri = cl_openxml_parturi=>create_from_partname( lv_uri ).
lo_xml_part = lo_package->get_part_by_uri( lo_xml_part_uri ).
lv_data_xstring = lo_xml_part->get_data( ).
But then, I don't know how to edit this data and overwrite the data for this one sheet and re-save it in the file.
Any help is greatly appreciated!
Thanks,
Vincent