Flexcel v. 7.22 - external linked, embedded excel files

A customer uses external linked excel files. Link has format "/Folder1/Folder2/ExcelFile.xlsx". The content of the extenal file is embedded. After loading and saving this Excel document in Flexcel the external content is missing as well as information for the "AlternateContent" in the file "workbook.xml".

As result the excel file cannot be used if the embedded file is missing.

Missing data in unzipped xlsx files:

  1. xl\workbook.xml:
    -node
  2. xl\externalLinks\externalLink.xml
    -node

Is this a configuration problem of the Flexcel object? What can I do to make this work?

Hi,
Can you send me an example of the file you are using? We don't really support embedding one xlsx file inside another, and I am not really sure of what functionality you are using to do so. If it is OLE (embedded objects), then sadly this isn't supported and isn't in our plans to do so, but if it is something else that I am not aware of we might be able to support it.

About "AlternateContent" missing this is expected and shouldn't affect the files: In the AlternateContent stream go features that are new and implemented in a different way. If we don't support such a new feature (or it if really doesn't affect the file at all) we might not write it back.

SavedWithFlexcel.xlsx (28.7 KB)
Template.xlsx (35.0 KB)

Hello Adrian,

Template.xlsx is the file opened with Flexcel. After saving this file some parts in the xml-files are missing. Please compare xl\workbook.xml and xl\externalLinks\externalLink1.xml. Copying the missing parts into the flexcel file fixed the problem. So maybe it is possible to save these xml nodes if they are present.

Hi,
Thanks for the files, I was thinking the issue was about embedded objects, now I can see it more clearly.

Sadly it is a little more complex than just copying the parts: Those parts missing are a recalculating cache (so, as you mention, the file can be calculated without the linked files), and FlexCel assumes by default their data is likely invalid (because it almost always is), so it doesn't use them. FlexCel requires the real files in order to ensure everything is coherent. If you add the linked files to a TWorkbook and recalculate the full thing, FlexCel should calculate the full file and write the correct data, so you would see the file fine when you open it, even if the linked files aren't there. (see FlexCel API Developer Guide | FlexCel Studio for VCL and FireMonkey documentation )

Note that if you use a TWorkbook to calculate the real file the file will be ok, you will be able to see it, but it still won't have the full linked recalculation cache, as it isn't really needed and normally ends up with outdated data.

The design decision of not using the cache just is because as said, in our experience this data is almost always outdated, and if you are creating a new file to send to your customers (most common FlexCel use case), this just leads to files with wrong data and very difficult to find bugs. Also there are real security concerns in embedding the data from other files, that's why we require you to manually specify the real files you want to link. (I had a question a month ago about this by a customer who is doing a security audit of his app, and luckily we do the right thing on that)

What we could do here is:

  1. For saving: We could write the full cache with sheet names + data (file externallink.xml) if you use a TWorkbook instead of writing just the sheet names as we do now. I don't see a problem with that, we just don't do it because it isn't needed: Excel will still show the right values without that cache if you calculated it right when you saved it.
  2. For opening: We could have a mode where we read the cache if the files are missing, but that would be off by default. Excel and FlexCel have different use cases: Excel is an interactive app where is easy to show a dialog telling you "the cache is outdated", but FlexCel is non-interactive and we just need to create the file you told us without warning you. And the idea is that if you are dealing with linked files, you have all the linked files, why would you use them if not?

But I can see some use cases for it, so I'll add this request of reading the data from the cache to our todo list.

About AlternateContent in xl\Workbook, what I see missing is:

 <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <mc:Choice Requires="x15">
      <x15ac:absPath url="\\Test\d$\Test\Reports\Templates\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
    </mc:Choice>
  </mc:AlternateContent>

As you can see, this ' Requires="x15" ' which means it is only for Excel 2013 and newer. Linked files work since Excel 5 at least, so this isn't really needed for linked files to work, and I personally never understood why would we want to save the full absolute path of the linked files. This is again just redundant data that can get out-of-sync with the real data of where the files are (the filenames of the linked files are in externalLink1.xml.rels ). So we made a conscious decision not to save that data. It adds nothing (the filenames Excel uses are not there), it can end up having a different value if you manually edit the file, and having full, not relative filenames is a small security risk: It could be giving away names of servers in your organization that you didn't mean to be public.

Hi Adrian,

thanks for the detailed explanation. The security aspect is something to convince the client to do without these embedded data. I guess the main reason it is used is that it works in Excel.

So on your part no action is required in this case.

And some information why I think outdated files were no problem:

The embedded file contained data from the last month for a closed accounting period. So in this case a change of the data is unlikely.