Posts

Showing posts from December, 2021

ABAP read excel(.XLSX) file to internal table in ABAP using CL_FDT_XL_SPREADSHEET

You are given a requirement to upload data to a custom DB table where the user provides you with the file path of the excel on his PC and the report loads the data from it to the Custom table. For experienced Abapers, the requirement is quite straightforward, except that the user wants to upload an XLSX file. There are not many options to read data from XLSX/XLS file. The TEXT_CONVERT_XLS_TO_SAP  function module is one of them but is a performance killer and uses OLE. In this post, I wanted to showcase How we can read data from the XLSX files using CL_FDT_SPOREADSHEET class. Let's start with uploading the file. Now that we have the file in xstring table, let's pass it to CL_FDT_XL_SPREADSHEET to get its object reference. From the object reference, we can retrieve each worksheet data. The data is returned in the form of an anonymous data object which can be dereferenced into a field symbol and passed to the target internal table. Below is the cod