Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a 2nd sheet raise an exception #13

Open
shofetim opened this issue Jul 31, 2015 · 6 comments
Open

Adding a 2nd sheet raise an exception #13

shofetim opened this issue Jul 31, 2015 · 6 comments
Assignees
Labels
Milestone

Comments

@shofetim
Copy link

Using 0.3.0
Using this (simple) template
Created with LibreOffice Version: 4.4.2.2

As soon as I add a 2nd named sheet:

(ns bug
  (:require [excel-templates.build :as excel]))

(excel/render-to-file
  "templates/test.xlsx"
  "/tmp/out.xlsx"
  {"Sheet1" [{:sheet-name "Foo Squares"
               3 [[1 1] [2 4] [3 9]]}
              {:sheet-name "Bar Squares"
               3 [[5 25] [6 36]]}]})

The following error is raised:

java.io.IOException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: The part /xl/worksheets/_rels/sheet2.xml.rels does not have any content type ! Rule: Package require content types when retrieving a part from a package. [M.1.14]
        at org.apache.poi.POIXMLDocument.openPackage(POIXMLDocument.java:69)
        at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:263)
        at sun.reflect.GeneratedConstructorAccessor63.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at clojure.lang.Reflector.invokeConstructor(Reflector.java:180)
        at excel_templates.build$render_to_file.invoke(build.clj:401)
        at bug$eval19263.invoke(form-init533457289181712521.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6703)
        at clojure.lang.Compiler.eval(Compiler.java:6666)
        at clojure.core$eval.invoke(core.clj:2927)
        at clojure.main$repl$read_eval_print__6625$fn__6628.invoke(main.clj:239)
        at clojure.main$repl$read_eval_print__6625.invoke(main.clj:239)
        at clojure.main$repl$fn__6634.invoke(main.clj:257)
        at clojure.main$repl.doInvoke(main.clj:257)
        at clojure.lang.RestFn.invoke(RestFn.java:1523)
        at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__10024.invoke(interruptible_eval.clj:67)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.core$apply.invoke(core.clj:624)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:51)
        at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__10066$fn__10069.invoke(interruptible_eval.clj:183)
        at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__10059.invoke(interruptible_eval.clj:152)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Possibly related to #4 and #7

@tomfaulhaber tomfaulhaber self-assigned this Aug 3, 2015
@tomfaulhaber
Copy link
Owner

Yup, I can reproduce that here. I'll take a look. Thanks for the nice bug report.

@shofetim
Copy link
Author

shofetim commented Aug 3, 2015

I've been playing with it abit, I think the problem may be something in LibreOffice, everything seems to work if the template was created by MS Excel 2007

@tomfaulhaber
Copy link
Owner

That was going to be my first guess. This is interesting, because I think it's actually on the 2nd pass that it fails. That is, we read the template, write to an intermediate with the first result sheet and then try to read the intermediate back, and that's when it breaks (I think).

@tomfaulhaber
Copy link
Owner

The problem here is worse that reported. I cannot open any spreadsheet that's based on a LibreOffice template in either Excel or Libre Office. If I comment out the second sheet, the program completes without errors, but the resulting spreadsheet makes Excel throw errors on open and is empty in Libre Office.

@shofetim
Copy link
Author

shofetim commented Aug 6, 2015

I'm unsure what the underlying bug with LibreOffice is, but FWIW I was able to create the templates with Google Sheets, exported as MS Excel 2011. Which is much more convenient then running a VM to get Excel setup.

@tomfaulhaber
Copy link
Owner

There's no bug in LibreOffice here, I don't think. I think that the problem is in POI and the way we use it. When we transform the workbook, we add a drawing where there was none before. I am going to start by resolving #26 and updating the program to use the new .getDrawingPatriarch method to see if that solves this problem.

Therefore, this issue depends on #26.

@tomfaulhaber tomfaulhaber added this to the 0.3.3 milestone Mar 20, 2016
@tomfaulhaber tomfaulhaber modified the milestones: 0.4.0, 0.3.3 Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants