Can't open exported .xlsx file

I'm trying to open an exported .xlsx file but I got this error from Excel:

Excel cannot open the file "file.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

I opened the file in text format and got this error:

Invalid parameter: Card 9 does not have a template tag named nil.

Metabase version is 0.45.1 and it reads from MySQL 5.7.38 as a data source.

Could you help please?

Hi @obadaqaf
You are seeing the following issue:
https://github.com/metabase/metabase/issues/20868 - upvote by clicking :+1: on the first post

Upvoted. Having the same issue at v0.47.9

Exact same issue? Did you open the file and saw that same one?

I created a simple SQL that returns a table. I exported to .xlsx and the same error as the OP posted. i.e.

Excel cannot open the file "file.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

Image:

please open the file and provide the error

The above error message was the error I got. Opening in text editor, I get:

{"via":[{"type":"java.lang.NoClassDefFoundError","message":"Could not initialize class sun.awt.X11FontManager","at":["sun.font.PlatformFontInfo","createFontManager","PlatformFontInfo.java",37]},{"type":"java.lang.ExceptionInInitializerError","message":"Exception java.lang.UnsatisfiedLinkError: /usr/local/openjdk-21/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory [in thread "streaming-response-thread-pool-28"]","at":["jdk.internal.loader.NativeLibraries","load","NativeLibraries.java",-2]}],"trace":[["jdk.internal.loader.NativeLibraries","load","NativeLibraries.java",-2],["jdk.internal.loader.NativeLibraries$NativeLibraryImpl","open","NativeLibraries.java",331],["jdk.internal.loader.NativeLibraries","loadLibrary","NativeLibraries.java",197],["jdk.internal.loader.NativeLibraries","loadLibrary","NativeLibraries.java",139],["jdk.internal.loader.NativeLibraries","findFromPaths","NativeLibraries.java",259],["jdk.internal.loader.NativeLibraries","loadLibrary","NativeLibraries.java",249],["java.lang.ClassLoader","loadLibrary","ClassLoader.java",2427],["java.lang.Runtime","loadLibrary0","Runtime.java",916],["java.lang.System","loadLibrary","System.java",2059],["sun.font.FontManagerNativeLibrary$1","run","FontManagerNativeLibrary.java",58],["java.security.AccessController","doPrivileged","AccessController.java",319],["sun.font.FontManagerNativeLibrary","","FontManagerNativeLibrary.java",33],["sun.font.SunFontManager$1","run","SunFontManager.java",269],["sun.font.SunFontManager$1","run","SunFontManager.java",267],["java.security.AccessController","doPrivileged","AccessController.java",319],["sun.font.SunFontManager","initStatic","SunFontManager.java",267],["sun.font.SunFontManager","","SunFontManager.java",262],["sun.font.PlatformFontInfo","createFontManager","PlatformFontInfo.java",37],["sun.font.FontManagerFactory","getInstance","FontManagerFactory.java",51],["java.awt.Font","getFont2D","Font.java",526],["java.awt.Font","canDisplayUpTo","Font.java",2278],["java.awt.font.TextLayout","singleFont","TextLayout.java",469],["java.awt.font.TextLayout","","TextLayout.java",530],["org.apache.poi.ss.util.SheetUtil","getDefaultCharWidth","SheetUtil.java",301],["org.apache.poi.xssf.streaming.AutoSizeColumnTracker","","AutoSizeColumnTracker.java",117],["org.apache.poi.xssf.streaming.SXSSFSheet","","SXSSFSheet.java",95],["org.apache.poi.xssf.streaming.SXSSFWorkbook","createAndRegisterSXSSFSheet","SXSSFWorkbook.java",726],["org.apache.poi.xssf.streaming.SXSSFWorkbook","createSheet","SXSSFWorkbook.java",745],["org.apache.poi.xssf.streaming.SXSSFWorkbook","createSheet","SXSSFWorkbook.java",102],["dk.ative.docjure.spreadsheet$add_sheet_BANG_","invokeStatic","spreadsheet.clj",351],["dk.ative.docjure.spreadsheet$add_sheet_BANG_","invoke","spreadsheet.clj",347],["metabase.query_processor.streaming.xlsx$fn__61542","invokeStatic","xlsx.clj",503],["metabase.query_processor.streaming.xlsx$fn__61542","invoke","xlsx.clj",500],["clojure.lang.MultiFn","invoke","MultiFn.java",234],["metabase.query_processor.streaming$streaming_context","invokeStatic","streaming.clj",145],["metabase.query_processor.streaming$streaming_context","invoke","streaming.clj",138],["metabase.query_processor.streaming$streaming_context","invokeStatic","streaming.clj",151],["metabase.query_processor.streaming$streaming_context","invoke","streaming.clj",138],["metabase.query_processor.streaming$streaming_response_STAR_$fn__61692$fn__61693","invoke","streaming.clj",166],["metabase.query_processor.streaming$streaming_response_STAR_$fn__61692","invoke","streaming.clj",165],["clojure.lang.AFn","applyToHelper","AFn.java",156],["clojure.lang.AFn","applyTo","AFn.java",144],["clojure.core$apply","invokeStatic","core.clj",667],["clojure.core$with_bindings_STAR_","invokeStatic","core.clj",1990],["clojure.core$with_bindings_STAR_","doInvoke","core.clj",1990],["clojure.lang.RestFn","applyTo","RestFn.java",142],["clojure.core$apply","invokeStatic","core.clj",671],["clojure.core$bound_fn_STAR_$fn__5818","doInvoke","core.clj",2020],["clojure.lang.RestFn","invoke","RestFn.java",421],["metabase.async.streaming_response$do_f_STAR_","invokeStatic","streaming_response.clj",69],["metabase.async.streaming_response$do_f_STAR_","invoke","streaming_response.clj",67],["metabase.async.streaming_response$do_f_async$task__39658","invoke","streaming_response.clj",88],["clojure.lang.AFn","run","AFn.java",22],["java.util.concurrent.Executors$RunnableAdapter","call","Executors.java",572],["java.util.concurrent.FutureTask","run","FutureTask.java",317],["java.util.concurrent.ThreadPoolExecutor","runWorker","ThreadPoolExecutor.java",1144],["java.util.concurrent.ThreadPoolExecutor$Worker","run","ThreadPoolExecutor.java",642],["java.lang.Thread","run","Thread.java",1583]],"cause":"Exception java.lang.UnsatisfiedLinkError: /usr/local/openjdk-21/lib/libfontmanager.so: libfreetype.so.6: cannot open shared object file: No such file or directory [in thread "streaming-response-thread-pool-28"]","_status":500}

Happy to provide any more information if you want to direct me to what you're looking for.

Just a quick update. I am still getting the error after updating to 0.48.5.

I've been combing through the internet to see what might fix this. Most of the suggestions revolve around ensuring Excel saves as .xslx by default. Checking/updating Security permissions. I've even renamed the file to something much shorter than the long default filename. I've renamed the extension to .xls. Tried to repair the .xlsx. None of these are working. I'm at a standstill and and I have no idea what is causing this or how to fix it.

You haven’t installed fonts maybe? How did you deploy Metabase?

We are deploying MB via Redhats Openshift platform using postgres as the app db.

How would one install fonts on MB?

e.g. metabase/bin/docker/Dockerfile at c8fb1bec7ab10132992d573c40f4fca097720ca7 · metabase/metabase · GitHub

Is that something we'd have to install separately from the .jar file?

hello @rossi45, do you still have the same issue?
I got the same thing on .xlsx output, and there is no new deployment or installed any font (unless installing font is an automatic thing)

Just for the record: if you build your own container or if you run the JAR, you need to install external fonts for making this work