Saving standard XLSM Excel with Macros as XLSB (Excel binary) - excel

I have a large project with Excel VBA files. Planning on moving from the xlsm file format to the xlsb (Excel binary). When I save the xlsm file as an xlsb I get warning.
It displays "abc.xlsm contains features that this version of Microsoft Excel can't save in another file format. Do you want to continue saving in this format and remove these features?"
Didn't know that xlsm can contain stuff that xlsb can't. Would be curious to know what exactly that is.
Anybody got an idea what the problem could be?

Related

How does Microsoft Excel detect encoding of .xls or .xlsx files?

Sometimes Excel fails to open .xls or .xlsx files with UTF-8 with right encoding and I couldn't find any encoding settings for a particular file when writing. How does Microsoft Excel detect encoding of .xls or .xlsx files?
Up to now, my research is:
.xls format is used for Office 97 to Office 2003(inclusive), called BIFF8 format. The text data inside is always encoded as UTF-16. So when Excel 97 opens an .xls file, no detecting is needed.
.xlsx format is used for beyond 2003 and is an XML format. I'm not sure if specifying encoding at top XML level is valid to Excel or has any significance.

EPPlus Adding VBA Code Corrupts resulting xlsx file

I'm creating an excel file using EPPlus from a datatable and saving it to a file, all fairly standard. This works without any hassles. However, if I create a vba project, and add any vba code, the resulting .xlsx file is suddenly corrupted. When try and open it with 2013, you get the standard error.
"Excel cannot open the file 'xyz.xlsx' because the file format or file
extension is not valid. Verify that the file extension matches the
format of the file.
If I change the extension to .xls, the file opens ok, and the script runs fine. I'm on the latest beta of Epplus (4.5.0.1). Should I just change the file extension and stick to .xls, or is there something amiss?
ExcelPackage.Workbook.CreateVBAProject()
ExcelPackage.Workbook.CodeModule.Code = "'Script is here"
Dim FInfo as new FileInfo("C:\Myfiles\ThisFile.xlsx")
ExcelPackage.SaveAs(FInfo)
You can not add VBA code to XLSX file format.
Take a look at here
.xlsx:
The default XML-based file format for Excel 2007-2013. Cannot store
Microsoft Visual Basic for Applications (VBA) macro code or Microsoft
Office Excel 4.0 macro sheets (.xlm).
Also take a look at here
to see differences between different formats:
XLSM If you include VBA macros in your XLSX file, you will be asked to
change the file extension to XLSM. Only that way you can save your
macro within the Excel file (there are other file types possible, e.g.
XLSB – but you can’t use XLSX for VBA macros)
Save your file as XLSM and it should work.

What is the difference between .xls file exported with Display tag and created with Excel

I use Display tag in Struts 1.3 to export a table to .xls file.I can export this without any problem and I can open this file with a text editor and view or edit.
<display:setProperty name="export.excel.filename" value="Export.xls"/>
Then created .xls file in Excel 2003 and try to edit it with text editor, but it's binary file.
The file size created with Excel is much bigger comparing to exported file.
Furthermore, When I try to open the exported .xls file in Excel 2013 it gives following popup,
"The file format and extension of 'Export.xls' don't match.
The file could be corrupted or unsafe.
Unless you trust its source ,don't open it.
Do you want to open it anyway ? (Yes/No/Help)"
What is the reason for this?
I found the reason behind this.The exported Excel(.xls) from displaytag is text-based excel and not a POI-based excel.But Excel application creates binary .xls file.

using MS XLSB instead of MS XLS

I need opinion on switching from MS XLS to XLSB. I have several models on MS xls file (Microsoft Excel 97-2003 Worksheet .xls) and have been using those models since many years. The xls files has lot of data, it has formula, macros, add-ins, formula to pull data from databases such as Bloomberg, Factset or Haver. I am planning to shift the model from MS Xls to MS xlsb i.e. binary format, however want to be sure if everything would work fine in binary format.
Can you please let me know if MS xls files are completely compatible with MS xlsb? ? Is there any disadvantage of using XLSB? Would be really thankful for your help.
XLS and XLSB are different file formats. The big disadvantage of XLSB is that it only works in Excel 2007+, so you can't depend on add-ins that only work in Excel 2000.
If your file works correctly in Excel 2007 or 2010 or 2013, then XLSB will preserve every feature from the XLS. This is different from XLSX, where many features are intentionally omitted.

Excel automation: Get a reasonable file format/extension for saving

In our Delphi app we automate MS Excel 2007 to generate and save a xls/xlsx file. How should we go about choosing a file format and extension for the generated file?
Hardcoding some values (e.g. xlOpenXMLWorkbook and .xlsx) doesn't work if the user has an older version of Excel installed. Not specifying a format probably works for older versions too (we're checking this right now) but leaves the question what the correct extension is. E.g. using .xls under Excel 2007 results in a XLSX file with wrong extension which leads to complaints when you open it in Excel.
omit extension AND format:
activeworkbook.SaveAs "fred"
will save the file as the appropriate type, and supply the extension too. The file will be fred.xlsx in 2007+ and fred.xls in previous versions.

Resources