<cfset src = "/Users/andyjarrett/Documents/workspace/railo_extensions/railo_extension_cfpoi/webroot/courses.xls" />
<cfset inputStream = CreateObject("java", "java.io.FileInputStream").init(src) />
<cfset workbookFactory = CreateObject("java", "org.apache.poi.ss.usermodel.WorkbookFactory").init() />
<cfset workbook = workbookFactory.create(inputStream) />
I've also created a simple Java app to test (using the same jars) and this works fine.
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class scribble {
public static void main(String[] args) throws InvalidFormatException, IOException {
InputStream inp = new FileInputStream("/Users/andyjarrett/Documents/workspace/railo_extensions/railo_extension_cfpoi/webroot/courses.xls");
Workbook wb = WorkbookFactory.create(inp);
System.out.println(wb.getNumberOfSheets());
}
}
Its probably more to do with my understanding of the POI library but was wondering if anyone else can spot my error?
Regards,
Andy Jarrett
/micha
2010/12/28, Andy Jarrett <ma...@andyjarrett.co.uk>:
> no worries.
>
> Im thinking I might just make it available as an alpha this week so at least
> other people can play around with it.
>
>
> Andy Jarrett
> www.andyjarrett.com
> www.linkedin.com/in/andyjarrett
>
> *Ξ Please think before you print Ξ*
<cfscript>
//create the loader
local.paths = arrayNew(1);
// This points to the jar we want to load. Could also load a directory of .class files
local.paths[1] = expandPath('{railo-web-directory}'&'/lib/poi-3.7-20101029.jar');
local.paths[2] = expandPath('{railo-web-directory}'&'/lib/poi-ooxml-3.7-20101029.jar');
local.paths[3] = expandPath('{railo-web-directory}'&'/lib/poi-ooxml-schemas-3.7-20101029.jar');
if( NOT structKeyExists( server, "_loader")){
server._loader = createObject("component", "javaloader.JavaLoader").init( local.paths );
}
//at this stage we only have access to the class, but we don't have an instance
var classInstance = server._loader.create( arguments.javaclass);
</cfscript>
/micha
2010/12/30, Andy Jarrett <ma...@andyjarrett.co.uk>:
> I've managed to resolve my Java heap error for now by setting the source as
> trusted which prevents it from always being recompiled and loaded
>
>
> Andy Jarrett
> www.andyjarrett.com
> www.linkedin.com/in/andyjarrett
>
> *Ξ Please think before you print Ξ*
>> *Ξ Please think before you print Ξ*