function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naznin VhoraNaznin Vhora 

How to read excel file using apex class and visual force page

Hi Everyone,
I have a requirement in my code,where I need to read an excel file using apex class and visual force page.
I have searched my query,but no where I found the solution for it,everyone posted solution for reading csv file.
Can anyone please tell me that, Is this possible to read excel file using apex?
GhanshyamChoudhariGhanshyamChoudhari
I believe excel file we cant read.
alternate solution, change the .xlsx to .xml and upload the file in static resource or file or in an attachment. then you can read the file in the apex.

ex.
Attachment att =[SELECT BodyLength,Body,
                ContentType,Description,Id,
                Name,ParentId
                FROM Attachment WHERE ParentId = '0017F00000MMXXXXXX'];
blob b= att.Body;
String s = EncodingUtil.base64Decode(EncodingUtil.base64Encode(b)).toString();
system.ddebug('data@@'+s)


 
Naznin VhoraNaznin Vhora
Thank you Ghanshyam
I will try this solution.