You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Kipre, Bougnon E" <bo...@eds.com> on 2004/09/10 17:46:30 UTC
RE: help: i need to read an xls template file in a web applicatio
n
To add more flexibility, you could use properties file to key/value pair
1) Properties file RunTimeProperties.properties in your classpath will have
an entry :
EXCEL_FILE=<location>\SOME_FILE.XLS
...
2) In your code
String propFileName = "RunTimeProperties.properties";
Properties props = new Properties();
try
{
if(!propFileName.startsWith("/"))
propFileName = "/"+propFileName;
InputStream is =
this.class.getResourceAsStream("RunTimeProperties.properties");
if (is != null)
{
props.load(is);
is.close();
}
}
catch (IOException e)
{
System.err.println(" Class Load error for "+propFileName+" :
"+e.getMessage());
}
String excelFileName = props.getProperty("EXCEL_FILE");
// now your are ready to read the file using POI API
...
Note: You could archive to another location the file after processing.
-----Original Message-----
From: Sharma, Siddharth [mailto:Siddharth.Sharma@Staples.com]
Sent: Friday, September 10, 2004 11:20 AM
To: POI Users List
Subject: RE: help: i need to read an xls template file in a web applicatio n
You can use the classloader to load the excel file as an InputStream
provided you place the excel file in the classpath such as "WEB-INF/classes"
directory of the web application.
java.io.InputStream iStream =
this.getClass().getClassLoader().getResourceAsStream("somefile.xls");
There may be something in the POI API to do the same thing abstracting you
from this piece of code. I am not familiar with that, if one exists
-----Original Message-----
From: Steve [mailto:stephen@Basit.COM]
Sent: Friday, September 10, 2004 11:07 AM
To: POI Users List
Subject: help: i need to read an xls template file in a web application
in a deployed web application.....
from a java program on the web server (and also on the app server) I need to
read an xls file, as a template. any idea as to how to find out the path to
the xls file, or to get it as an InputStream? THANKS, Steve
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-user-help@jakarta.apache.org