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

How I can read xls file with apex class



I have written one email service through which I am attaching one xls file into record's attachment. I am able to read file if it is in .csv format but unable to read if it's in .xls format. Any idea how I can convert .xls to ,csv.


Thanks in advance.


You cannot convert an XLS to a CSV file in Apex Code. The file is in a pure binary format that is not well documented. Similarly, you won't be able to read an XLSX file, despite being well documented, because it is effectively a ZIP file, so you'd have to try and decompress it in memory, which would require far too many script statements for files larger than a few kilobytes.


Edit: This sounds awfully bleak, I realize. However, if you're *determined* to do this, you might consider writing a service in .NET or something that can interface with Excel directly, and then call that service from Apex Code. You'll be limited in file size, but it would be far better than the measly limits in place in Apex Code.




Thanks for quick respone!


Is there any way to convert it into json or xml through http call or any other api call.


with Regards