Jump to content
misc_bb

Working with Delphi and Excel

Recommended Posts

I know a lot of you might have worked with reading and writing Excel sheets with Delphi. I would like to ask if its possible to read an excel file without opening it?

Share this post


Link to post

I think I've read this article as well. Not interested in buying yet but we'll see. Thank you.

Share this post


Link to post
6 hours ago, misc_bb said:

read an excel file without opening it?

Uh, how do you expect to get the contents of a file without opening it? Or do you mean that you don't want to use OLE? I've used XLSReadWrite successfully.

  • Like 4

Share this post


Link to post
7 hours ago, misc_bb said:

I would like to ask if its possible to read an excel file without opening it?

No. It is not possible to read an excel file without opening it. 

 

However, I suspect that what you actually want to do is to read such a file without using an Excel process via its COM API. If that is what you want to do then it is indeed possible. 

  • Like 1

Share this post


Link to post
7 hours ago, misc_bb said:

I would like to ask if its possible to read an excel file without opening it?

Without using OLE? Yes. An .xlsx file is in .zip format. You can extract the contents using TZipFile and read the (mostly) xml files inside. You could learn the spec and parse the xml. Here's some links that might help:

 

https://docs.fileformat.com/spreadsheet/xlsx/
http://officeopenxml.com/anatomyofOOXML-xlsx.php
https://www.brendanlong.com/the-minimum-viable-xlsx-reader.html
https://c-rex.net/projects/samples/ooxml/e1/Whitepaper/spreadsheetml.html

 

Share this post


Link to post

A year or two ago, I used NPOI (.NET) for exporting to an excel sheet with formulas and different formats. It was a breeze

Free, widely used, but not in Delphi. You'd have to go with .NET and include that in your Delphi app.

Share this post


Link to post

HTML Office Library can read (and display) all office formats (XLS, XLSX, XLSB, DOC, DOCX, PPT, PPTX) and also PDF, EPUB, FB2, HTML, MD (markdown), EML, MSG (Outlook), WMF, EMF.

All platforms, only plain Delphi code.

Share this post


Link to post

@corneliusdavid Thank you. I think I'll go for this library. @Dave Nottage I'm currently using OLE but wanted to avoid Excel app from opening. Thank you for the suggestion but I've been thru a lot with OOXML working with docx files, I don't want to go there for the mean time. :classic_biggrin:

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×