0

I have a bean with method to generate report made with jett:

beans.put("list", list);

    try {
        String inPath  = ("/template.xls");

         ExcelTransformer transformer = new ExcelTransformer();
         transformer.transform(inPath, "report.xls", beans);

I'm having ioexception in transform.transformer (...) being that I put template.xls in src / main / resources as maven says and I still stated in pom:

<directory>src/main/resources</directory>
            <includes>
                <include>template.xls</include>
            </includes>

in fact I did equal the documentation of the jett and they do not explain much the. I already tried several combinations of path and nothing

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
philabreu
  • 55
  • 1
  • 7
  • You're asking about an exception, but you don't post the stack trace of the exception. Why? Also, what does the documentation of ExcelTransformer.transform() say about the arguments it expects? The one I've found says that they are **file names**. Do you have a file template.xls at the root of your file system? Aren't there other transform() method that you could use to pass the content of a resource found in the classpath, and not on the file system? – JB Nizet Sep 03 '17 at 15:54
  • Forgive me the exception is: java.io.FileNotFoundException: /template.xls 13: 06: 10,570 ERROR [stderr] (default task-24) IOException reading /template.xls in relation to the transform method I saw in the jett documentation was: void net.sf.jett.transform.ExcelTransformer.transform (String arg0, String arg1, Map arg2) throws IOException, InvalidFormatException so as inPath is string it seems to me that I'm passing right, right? – philabreu Sep 03 '17 at 16:06
  • 1
    The exception is quite clear: the **file** /template.xls doesn't exist. Note that it looks for a **file**. On the **file system**. It doesn't look for a classpath resource. Use MyClass.class.getResourceAsStream("/template.xls"), and pass the InputStream to transform(), instead of using the method expecting file names. – JB Nizet Sep 03 '17 at 16:09
  • Thanks for the help, it worked like it said! – philabreu Sep 04 '17 at 00:41

0 Answers0