I have a pretty basic question about the usage of jxls.
XLSTransformer transformer = new XLSTransformer();
transformer
.transformXLS(
"dummy.xls",
beans,
"dummyCreated.xls");
And this does not work.
The reason provided is that dummy.xls is not found. The dummy.xls is in the same location as the java class from which I have provided the snippet of code. If instead of dummy.xls I provide the fully qualified path ie D:\\myfolder\\theRestOfTheFolders\\dummy.xls, then it works.
But, I need the code to work without providing the entire path. I need the code to work by picking up the xls from wherever the calling class is.
I am sure I am missing some small juggling of the java io library. Any help is appreciated.
After a bit of fiddling around with jxls, I sort of gave up trying to make it pick up files from the location of the java file. So, I have given in and started passing it the actual file location.
<bean id="templateName" class="java.lang.String">
<constructor-arg value="C:\Template.xls" />
</bean>
And then I made my code pick it up.
@Autowired
private String templateName;
And after that the code became simply.
transformer.transformXLS(templateName, beans, outputFileName);
This is working now. However, if anyone have a different suggested solution, please write back.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.