Opening Microsoft File Formats to Java
by Avik Sengupta and Andrew Oliver01/22/2003
So you're a developer who creates cool but complicated server-side applications in Java, or you're an architect convinced about J2EE. Do your users care until they see an Excel spreadsheet on their desktops?
Until recently, your options were limited; pay a lot or move your application to a Windows box (see A Short History of POI below). Now, with the Jakarta POI project, you have a third option. POI (Poor Obfuscation Implementation, the name that seemed to describe the format best) is a high-quality application that can read and write Excel and other MS-format files right from inside of your Java application.
In this three-part series, we will see how the Jakarta POI project provides pure Java APIs to let you achieve this dream of interoperability.
Basics
Starting with Office 95, all MS Office applications store their documents in an archive called the OLE2 Compound Document Format (OLE2CDF). It's a bit like the old FAT filesystem: it promotes fragmentation, doesn't support compression, and isn't linear (which would make streaming easier). Other than that, it's great. What is it good for? The Microsoft Foundation Classes allow applications to serialize to this format (often in Property Sets, which we'll cover later), so if you need interoperability with legacy Windows proprietary file formats or Office documents, you have to deal with OLE2CDF.
Each OLE2CDF file on disk contains an entire filesystem, laid out using nested Directory Entries, which contain Entries. We are interested in Entry elements of the Document Entries type. A Document Entry contains application-specific (e.g. Excel) data structures.
|
Related Reading
|
POI
POI consists of various parts that fit together to deliver the data in
a MS file format to the Java application. At the lowest level is the POIFS (POI
FileSystem) API that contains the basic logic to process any OLE2CDF file.
Above that sit the various components to process the application data. HSSF
(Horrible SpreadSheet Format) understands the Excel structures, while HDF
(Horrible Document Format) understands the Microsoft Word structures. In this
article, we will look at how to use POIFS to read or write a OLE2CDF file. In
future articles of this series, we shall see how to use HSSF and HDF, as well
as HPSF (Horrible Property Sheet Format, used to read -- and eventually write
-- document property information available through
File->Property) and using the HSSF Cocoon Serializer
to serialize XML to an Excel file.
POIFS
Appendix 1 contains an example program that shows you how to use the POIFS API to read and write OLE2CDF files. Let's look at the important bits.
Reading a file is pretty easy:
POIFSFileSystem fs; // org.apache.poi.poifs
...
s = new POIFSFileSystem(inputStream);
The root (/) Directory Entry can be accessed by:
DirectoryEntry dir = fs.getRoot()
From there you can traverse the file format, which is structured like a filesystem -- directories, subdirectories and all. We can now iterate through the filesystem and access its Directory Entries:
for (Iterator iter = dir.getEntries(); iter.hasNext(); ) {
Entry entry = (Entry)iter.next();
System.out.println("found entry: " + entry.getName());
if (entry instanceof DirectoryEntry) {
// .. recurse into this directory
} else if (entry instanceof DocumentEntry) {
// entry is a document, which you can read
} else {
// We're not interested in any other type
}
}
For the moment, however, we are not interested in recursing through every
entry. In an XLS file, for instance, most of the data is available in an entry
called Workbook, in the root directory. We access it like this:
DocumentEntry document = (DocumentEntry)directory.getEntry("Workbook");
DocumentInputStream dstream = new DocumentInputStream(document);
From this point on, you can read the document the way you would any other InputStream in Java. Simple, isn't it?
Writing is equally easy. Watch!
// stream == InputStream of some type
// outfile = output file name
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry createdDir = fs.getRoot().createDocument("Workbook", stream);
OutputStream out = new FileOutputStream(outfile);
fs.write(out); // don't forget to close your output stream...
With those few lines of code, we can read the innards of an Excel file, and
write it out again in a way that Excel can read it. (Note, however, that we are
writing out only the Workbook stream, thereby losing information
in other streams. Macros and embedded objects are stored in a separate stream.)
There are other ways to do this more efficiently. The project is slowly migrating to a event-based API (or the "Reactor Pattern" of sorts) for reading. However, this is probably best saved for those experienced with the API; the online POIFS documentation covers this in more detail. The benefits of the reactor-based APIs are a smaller memory footprint and speed; the cost is a lower level of abstraction and bending your mind inside-out. Instead of grabbing a document, you have to do something when a document is pushed unto you.
Summary
Microsoft's OLE 2 Compound Document format once prevented Java programmers from reading and writing Office and MFC-generated file formats from pure Java. Java programmers often had to resort to native bridges which limited them to Microsoft Operating Systems. The Jakarta POI Project opens up new worlds to Java developers by allowing them to write to OLE2CDF-based file formats with pure Java -- even on UNIX. This article explained how to work with the underlying OLE 2 Compound Document Format. In the next article, we'll explain how to read, write, and Modify Excel files with HSSF. The final article will cover the HSSFSerializer for Cocoon, as well as HPSF and HDF.
References
Avik Sengupta
is the CTO at Itellix
Software Solutions and a contributor to the
Andrew Oliver is a professional cat herder who moonlights as a software developer and runs a small consultancy with an ugly retro looking website that one day will be updated when he and his compadres aren't too busy working with clients.
Appendix 1
Example 1
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import java.io.*; // don't ever do this...done to save space
/**
*Purpose: reads in an Excel file and outputs just the Workbook stream
* Usage: POIFSExample1 excelfile.xls workbook.dat
*/
public class POIFSExample1 {
public POIFSExample1() {};
public void run(String filename, String outfile) throws IOException {
InputStream istream = new FileInputStream(filename);
POIFSFileSystem fs = new POIFSFileSystem(new BufferedInputStream(istream));
DirectoryEntry directory = fs.getRoot();
DocumentEntry document = (DocumentEntry)directory.getEntry("Workbook");
DocumentInputStream dstream = new DocumentInputStream(document);
FileOutputStream ostream = new FileOutputStream(outfile);
byte[] buffer = new byte[1024];
while (dstream.read(buffer) > 0) {
ostream.write(buffer);
}
ostream.close();
dstream.close();
istream.close();
}
public static void main(String[] args) {
try {
POIFSExample1 example = new POIFSExample1();
example.run(args[0], args[1]);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Example 2
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.poifs.filesystem.Entry;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
import java.io.*; // don't ever do this...done to save space
/**
* Purpose: Read in the Workbook stream from Example 1
* and construct a new and valid Excel file
* using POIFS.
* Usage: POIFSExample2 workbook.dat excelfile.xls
*/
public class POIFSExample2 {
public POIFSExample2() {};
public void run(String filename, String outfile) throws IOException {
InputStream istream = new FileInputStream(filename);
POIFSFileSystem fs = new POIFSFileSystem();
DirectoryEntry directory = fs.getRoot();
directory.createDocument("Workbook", new BufferedInputStream(istream));
FileOutputStream ostream = new FileOutputStream(outfile);
fs.writeFilesystem(ostream);
ostream.close();
istream.close();
}
public static void main(String[] args) {
try {
POIFSExample2 example = new POIFSExample2();
example.run(args[0], args[1]);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Appendix 2
A Short History of POI (by Andrew C. Oliver)
About a year and a half ago, I was fortunate enough to land a short-term contract doing a small Web-based system that would output a few basic types of reports. Having done the project a few times, I knew what was coming over the horizon: customer mapping (ATT = AT&T = A T&T = AT&T Southeastern Division but AT&T Southeastern Division != ATT Northeastern Division), and ultimately, the big issue -- output to Microsoft Excel. That would be a bit easier on Windows, but on a Solaris server ...?
Fortunately, I knew of an inexpensive product from a small company that could write these files affordably and easily. It would be painful, because it was bound to AWT, which was bound to X libraries, but I was positive we could get around this issue.
Unfortunately, I discovered that the little company had been bought by a larger company and they'd raised the price into the low-five-figure range per processor. I had to sell the idea, so I did some competitive analysis and guessed that it would take six months and two developers to create a basic Excel API for Java. Alternatively, they could upgrade everyone to the latest version of Excel and keep their spreadsheets small enough (so as not crash Excel, as tends to happen with larger spreadsheets) and generate the pseudo-HTML XML format that Excel supported at the time. As you might guess, the client bought the package.
Well, I got to thinking, "once this project is over, what if I did this Excel project?" Even better, I was enamored with an Apache project called Cocoon. What if this was a serializer for Cocoon?
I soon discovered that it was not as simple as writing out Excel file format. I would also need to learn about a base file format called OLE 2 Compound Document Format.
I was fortunate enough to have the ever-so-talented Marc Johnson as a member of my local Triangle Java Users Group. He responded to an inquiry of mine, and six months later we had four developers, basic OLE 2 Compound Document Format, and could read and write basic Excel files. Shortly thereafter, we were the newest addition to the Apache Jakarta project. Since then, we've been joined by a number of talented developers. The rest, as they say, is history!
Return to ONJava.com.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 53 of 53.
-
How to read from Excel and write to MS Word in a pre-defined format?
2008-01-09 20:54:54 RaghuzJava [Reply | View]
Hi,
Please help me read from a MS XLS and write to MS Word in a Specific format.
Thanks!
-
reading and writing excel and database entries and writing it into new excelsheet
2007-03-05 22:47:57 bhavna13 [Reply | View]
i m facing a problem while i m creating an excelsheet.as i have to create a new excel sheet and store the data by reading from other excelsheet or from a database.
please help me to solve out this problem
bhavna -
reading and writing excel and database entries and writing it into new excelsheet
2007-11-12 00:46:45 kumar12345 [Reply | View]
how i will convert the excel sheet to PDF format with help of apache POI package in servlet and jsp in java. and what is the source code for this? -
reading and writing excel and database entries and writing it into new excelsheet
2007-08-31 03:15:41 Rupali. [Reply | View]
Hi Bhavna,
I need to look into the kind of code or entries you have to fetch form data base. Well till then, i can give you the general code for the same. It may be like,,
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Report");
FileOutputStream fileOutputStream = new FileOutputStream(exportFile);
Iterator rowIterator = tabularRows.iterator();
int rowCount = 0;
while (rowIterator.hasNext()) {
HSSFRow row = sheet.createRow(rowCount++);
String rowToExport = (String) rowIterator.next();
List<String> columnsToExportForRow = tokenizeString(rowToExport,
your string from database);
int cellCount = 0;
if (columnsToExportForRow != null && columnsToExportForRow.size() > 0) {
Iterator columnIterator = columnsToExportForRow.iterator();
// System.out.println("\n");
while (columnIterator.hasNext()) {
HSSFCell cell = row.createCell((short) cellCount++);
cell.setCellType(1); //store numbers as text
cell.setCellValue((String) columnIterator.next());
if (rowCount == 1) {
/**
* this is the header row. so decorate it
*/
HSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) 12);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle style = workbook.createCellStyle();
style.setFillBackgroundColor(HSSFColor.BLUE_GREY.index);
style.setFont(font);
cell.setCellStyle(style);
}
}// end of while (columnIterator.hasNext())
}// end of if(columnsToExportForRow!=null && ...
}// end of while(listIterator.hasNext())
try {
workbook.write(fileOutputStream);
if (fileOutputStream != null) {
fileOutputStream.close();
}
} catch (IOException e) {
responseString = "The report could not be generated due to an internal error.";
}
}// end of if(tabularRows!=null && tabularRows.size()>0)
} catch (FileNotFoundException e) {
responseString = "The report could not be generated due to an internal error.";
}
return responseString;
}
Try this code out and let me know if anything more you need to know on it.
Thanks.
Rupali
-
identifying an OLE object embeded inside Microsifte word/excel /PPT
2006-12-21 05:20:20 javaPOI [Reply | View]
Hi,
I am facing a critical problem in reading or identifying an OLE object embeded in a word document or Excel or PPT.
Is there any solution provided by POI to read a document provided its path alone and identify does the document have any object embeded inside it and what document is embeded?
Please help me in this.
Regards,
Rajashankar.R
-
How to Convert list of records in JSF to Excel Sheet
2006-12-13 02:01:33 VasanthaKumar [Reply | View]
Hi,
I am new to POI package. By using datatable in jsf i listed the records on the screen, now i need to write this records into Excel Sheet. Please help me !
Thanks
Vasanth
-
excel file display and edit in ie
2006-08-14 08:06:36 mab1777 [Reply | View]
I want to open an excel file in ie. Modify it and save it back to the excel file. Can I do this using POI-HSSF? Is there a size limitation using POI-HSSF?
Thanks,
Manon
-
XSL-FO to WORD
2006-02-23 02:46:03 amgad2002 [Reply | View]
is there any open source that uses POI to convert XSL-FO format to microsoft word format?
amgoody2002@yahoo.com
-
how to convert xml file to xls using POI
2006-01-02 01:53:18 kalaisai [Reply | View]
hi all,
plz any one help me how to work with POI .what are the files needed.how to run etc.its very urgent.plz!!!!!!
-
How to read word document without using POI?
2005-12-09 00:55:13 indianattech [Reply | View]
Hi All,
I am trying to understand the word document format.
But it seems I am missing somewhere in identifying the FIB block,
After moving to the 24th byte, I am not getting the exact values. I do not why. In order to check whether I am doing the right thing or not I have written below test program for which I am getting alswys some unknown values. Even for the small files also fcMin position value is showing bigger than the actual file size
import java.io.*;
class WordTest
{
public static void main(String[] args)
{
try {
for(int i=0;i{
File f = new File("c:\\a.doc");
RandomAccessFile raf = new RandomAccessFile(f, "r");
raf.seek(i);
// System.err.println(raf.readByte()+" "+raf.readByte()+" "+raf.readByte()+" "+raf.readByte());
System.err.println(i+" "+raf.readInt());
//0011111000000000
raf.close();
Thread.sleep(10);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Can anbody give me the answer for this?
Thanks & Best Regards
-
Where can i find the doc file contents..
2005-11-20 22:35:45 Althafuddeen [Reply | View]
hi,
POI classes are working fine in my PC.NOw
I want to get the contents (individual words) within the doc file.So let me know in which class it is stored?..if in other format, how to convert it?.Waitin for reply -
How to read word document without using POI?
2005-12-09 00:53:56 indianattech [Reply | View]
Hi All,
I am trying to understand the word document format.
But it seems I am missing somewhere in identifying the FIB block,
After moving to the 24th byte, I am not getting the exact values. I do not why. In order to check whether I am doing the right thing or not I have written below test program for which I am getting alswys some unknown values. Even for the small files also fcMin position value is showing bigger than the actual file size
import java.io.*;
class WordTest
{
public static void main(String[] args)
{
try {
for(int i=0;i{
File f = new File("c:\\a.doc");
RandomAccessFile raf = new RandomAccessFile(f, "r");
raf.seek(i);
// System.err.println(raf.readByte()+" "+raf.readByte()+" "+raf.readByte()+" "+raf.readByte());
System.err.println(i+" "+raf.readInt());
//0011111000000000
raf.close();
Thread.sleep(10);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Can anbody give me the answer for this?
Thanks & Best Regards -
Where can i find the doc file contents..
2005-12-09 00:53:01 indianattech [Reply | View]
Hi All,
I am trying to understand the word document format.
But it seems I am missing somewhere in identifying the FIB block,
After moving to the 24th byte, I am not getting the exact values. I do not why. In order to check whether I am doing the right thing or not I have written below test program for which I am getting alswys some unknown values. Even for the small files also fcMin position value is showing bigger than the actual file size
import java.io.*;
class WordTest
{
public static void main(String[] args)
{
try {
for(int i=0;i{
File f = new File("c:\\a.doc");
RandomAccessFile raf = new RandomAccessFile(f, "r");
raf.seek(i);
// System.err.println(raf.readByte()+" "+raf.readByte()+" "+raf.readByte()+" "+raf.readByte());
System.err.println(i+" "+raf.readInt());
//0011111000000000
raf.close();
Thread.sleep(10);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Can anbody give me the answer for this?
Thanks & Best Regards
-
how to use poi package in my project
2005-09-23 03:15:46 janaki1 [Reply | View]
Hai all,
This IS Chaitanya
I down load the "poi-bin-2.5.1-final-20040804.ZIP
And I wrote the program like this
import com.sun.rsasign.s;
import java.io.*;
import java.util.*;
public class Rdata {
/** Creates a new instance of Rdata */
public Rdata() {
}
public static void main(String a[])throws Exception
{
FileReader fr=new FileReader("c:\\java\\abc.doc");
FileWriter fw=new FileWriter("C:\\java\\a.txt");
FileWriter fw1=new FileWriter("C:\\java\\b.doc");
int i;
char ch;
String str="",f="";
while((i=fr.read())!=-1)
{
ch=(char)i;
if(ch!='\n')
{
str=str+ch;
}
else
{
StringTokenizer st = new StringTokenizer(str);
while (st.hasMoreTokens())
{
f=st.nextToken();
f.trim();
f.toLowerCase();
{
while((i=fr.read())!=-1)
{
ch=(char)i;
fw.write(ch);
fw.write("\r\n");
}
}
{
fw1.write(ch);
fw1.write("\r\n");
}
}
str="";
}
}
fw.close();
fw1.close();
}
}
BUT WHEN I AM OEN THE .DOC FILRS Unexpected garbage values.How to use this poi package in my program.I want Immediate solution to this can Any body help me plz.
thanks in advance. -
how to use poi
2006-01-02 01:57:35 kalaisai [Reply | View]
hai ,
i'm new to this POI in java.i know JSF.how to run a small prg in this.plz give idea.what are the files needed.how to run it etc.
plz do so help me itz urgent.
thanks in advance
by
kalaivani
-
how to use poi
2007-08-02 23:40:44 TARZAN [Reply | View]
Hi...
i am new to this forum and this is the easy way to use poi package.example code is below which reads the data from "new.txt"(data is:aa/bb/cc/dd/4Mhz/66/gg/hh/ii/jj/kk/ll/44GHZ/123/oo/) and stores this data into the "today.xls" under C drive. i am extracted this data based on key "/" and each data is stored in one cell liek aa in (0,0)and bb in (0,1)like wise.
once you compile and run new file will be created and data will be written that is "aa
aa" in two cells and again this code is executed it appends the new data which is read from "new.txt" with old data in same file.
**********************************************
import java.io.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.util.*;
//import org.apache.poi.hssf.util.HSSFColor;
class exceltest{
public static void main(String arg[])throws IOException{
File f=new File("c:\\today.xls");
if(f.exists()){
FileInputStream fin=new FileInputStream(f);
FileInputStream fin1=new FileInputStream("c:\\new.txt");
int size=fin.available();
byte arr[]=new byte[size];
fin1.read(arr,0,size-2);
String str=new String(arr);
String strarr[]=new String[14];
strarr=str.split("/");
HSSFWorkbook wb=new HSSFWorkbook(fin);
HSSFColor col=new HSSFColor.SEA_GREEN();
HSSFCellStyle cs=wb.createCellStyle();
HSSFFont style= wb.createFont();
style.setFontHeightInPoints((short)10);
cs.setFillPattern(HSSFCellStyle.FINE_DOTS);
//cs.setFillBackgroundColor(col.getIndex());
style.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
style.setColor(HSSFFont.COLOR_RED);
HSSFSheet ws1=wb.getSheet("January");
HSSFRow wr1=null;
Integer c=ws1.getLastRowNum();
int count=c;
Integer c1=new Integer(1);
System.out.println("Before : "+c.toString(c));
short rownum1=c.shortValue();
short rownum2;
rownum2=c1.shortValue();
rownum1=(short)(rownum1+rownum2);
System.out.println("After : "+Short.toString(rownum1));
cs.setFont(style);
wr1=ws1.createRow(rownum1);
for(short cellnum1=0;cellnum1HSSFCell wc1=wr1.createCell(cellnum1);
//wc1.setCellStyle(cs);
String ss=strarr[cellnum1].trim();
if(ss.equals("66")||ss.equals("123")){
System.out.println(ss);
wc1.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
}
else{
wc1.setCellType(HSSFCell.CELL_TYPE_STRING);
}
wc1.setCellValue(strarr[cellnum1].trim());
}
FileOutputStream fout=new FileOutputStream(f);
wb.write(fout);
fout.close();
}
else{
FileOutputStream fout=new FileOutputStream("c:\\today.xls");
HSSFWorkbook wb=new HSSFWorkbook();
System.out.println("Writing...");
HSSFSheet ws=wb.createSheet("January");
HSSFRow wr=null;
for(short rownum=0;rownum<2;rownum++){
wr=ws.createRow(rownum);
for(short cellnum=0;cellnum<2;cellnum++){
HSSFCell wc=wr.createCell(cellnum);
wc.setCellValue("aa");
}
}
wb.write(fout);
fout.close();
}
}
}
before executing this code you require jakarta POIpackage any version but i checked with poi 3.0
steps:
1.download the package and extract the file andyou may find the file like "poi-3.0-rc4-20070503.jar" and put it in c drive or whichever you feel
2.compile the code (Note: specifying the jar file is must otherwise may get error like package HSSFWorkbook does not exit and etc..)
javac -Xlint -classpath c:\poi-3.0-rc4-20070503.jar exceltest.java
3.Run the application
java -cp c:\poi-3.0-rc4-20070503.jar;. exceltest
Note: this gives the 2-warnings
-
problem with poi
2005-01-20 21:02:33 Nana [Reply | View]
i got some steps to run poi programs from this site.
the steps are as follows.
1.download "poi-bin-2.5.1-final-20040804.zip"
file
2.extract it to the folder say
c:\poi-bin-2.5.1-final-20040804
3. and then simply add to the classpath..
"c:\poi-bin-2.5.1-final-20040804\poi-2.5.1-final-20040804.jar"
but after the classpath is set, the 'java' command(command to run .class files) is not working.
it gives NoClassDefFoundError exception.
but compilation is working successfully.
what is the problem?
What is the minimum version of java to execute poi?
i need an immediate reply.
thank you
bye
nana
-
Openoffice and POI
2004-04-21 10:02:32 Ubaldo [Reply | View]
Hello, I tried to use poi and openoffice spreadsheet saved as Microsoft Excel 97/200/XP format, but i found that didn't work in many examples.
Is it possible to use POI with openoffice or the only way to do that is using the openoffice's API ?
-
Intersted Excel Charting manipulation
2003-05-16 05:55:32 anonymous2 [Reply | View]
I'm interested in seen how to do Charts trought POI. It seems posible if the chart is there already and one populate the data sheet with POI. -
Intersted Excel Charting manipulation
2004-01-13 18:32:53 anonymous2 [Reply | View]
Use ExtenXLS -- you can modify Charts all you want.
Hey, POI is pretty good, but I think if you want a really good Java Excel tool with commercial support that you should check out ExtenXLS.
We use and recommend the Java Excel API ExtenXLS, which you can download here from Extentech's web site at:
DOWNLOAD NOW!
This tool is so slick and works so well, we've never even needed support!
Used by JPMorgan/Chase, HP, Ford, and more, so you know it's solid... -
Intersted Excel Charting manipulation
2007-02-02 04:37:49 liqd [Reply | View]
Jxcell is also a good choise to genarate excel apreadsheet file with chart support.
- http://www.jxcell.net
-
Intersted Excel Charting manipulation
2004-01-13 21:08:31 anonymous2 [Reply | View]
I work for JPMorgan/Chase and we're using POI. -
Intersted Excel Charting manipulation
2004-01-13 21:06:59 anonymous2 [Reply | View]
We tried ExtenXLS and it just didn't scale well. It often corrupted files and just didn't do what we needed. POI worked great for us. -
Intersted Excel Charting manipulation
2005-07-18 14:19:53 johnny_shredder [Reply | View]
POI is good, no doubt about it. Extentech has a solid product and should not be overlooked especially if you have a budget and want to have more robust handling of existing files.
The older versions of ExtenXLS had scalability problems, however the new version of ExtenXLS (4.1) has fixed this, and is now far more compatible with complex Excel files than POI -- especially files with embedded OLE objects, etc.
ExtenXLS now also not only allows you to create formulas from text strings (like: =sum(a1+b1)) but it will *execute* the formulas in memory. It can then use an XSLT to transform the Java Excel WorkBook to HTML (out of the box) PDF or whatever. A great way to re-use existing Excel files in your applications.
If you want a great supported product, at a reasonable cost considering it includes unlimited support and upgrades, check it out at
http://www.extentech.com/estore/product_detail.jsp?product_group_id=1
-
How can i read an image from excel and write to a file
2003-04-24 05:45:39 anonymous2 [Reply | View]
Hi,
I would like to know how we can read a set of images from excel file with their names and store that files in a folder
-
POI download
2003-04-23 01:43:07 anonymous2 [Reply | View]
I'm a novice programmer and don't understand much ofthe ttoo technical stuff. I nid this for our school proj. How do I use POI? where do i get the API?
-
When is part 2 coming out
2003-03-19 12:11:12 anonymous2 [Reply | View]
I've been waiting since this article for part 2! I'm anxious to read about Excel and Word...
-
POI is very nice...
2003-02-07 15:13:34 anonymous2 [Reply | View]
I had to (shudder) read MS Excel docs in a recent project (in addition to CSV and XML) for data upload to a (very) large system. POI has worked extremely well for this.
-
Ugliest of 'em all...
2003-02-06 06:37:10 anonymous2 [Reply | View]
is probably PowerPoint and I'd love to see some sample code how to interact with the streams inside the file.
-
Ugliest of 'em all...
2003-02-06 06:36:17 anonymous2 [Reply | View]
is probably PowerPoint and I'd love to see some sample code how to interact with the streams inside the file.
-
An alternative that may work in some situations
2003-02-01 15:44:36 anonymous2 [Reply | View]
I got round the problem of presenting data using any of the office components as follows.
This method relies on two things.
1. You can use a web server to transfer a file to the client
2. The client enables macros (or you sign them)
My site works like this. When a user clicks on a report Icon (say for MS Project) a .mpp file is sent to their browser which they then open. The autoexec macro looks at the filename and picks off the ipaddress and some parameters. The macro then sends a request to the same Java servlet that sent the file with a ?MPP=Y switch and the other parameters by using the VB FileOpen (Workbooks.OpenText in Excel) to import a .csv file but from the servlet URL. The code is at the bottom.
I then use my servlet to send back a bunch of records as .csv.
I then use VB to handle all of the custom formatting, to make the data look pretty, add header and footer information etc. I actually transmit the header and footer information at the start of the .csv and make sure the macro knows what to truncate before opening the .csv.
I know it is not for everyone but it does save messing with custom file formats and I reckon tweaking some VB code to get the data to look right is probably a bit easier. Also it works with Word, Excel, Project and probably any other office component that can import .csv, .txt or maybe even XML!
Send me an email if you want the code writetojon at hotmail
Here is the VB macro
Sub Auto_Open()
' Determine remote_user, RVID and IP address from filename passed in
' in the form [CDSI][RVID][x].[IPAD].xls
S = ActiveWorkbook.Name + ".xls"
CDSI = Mid(S, 2, InStr(1, S, ")") - 2)
RVID = Mid(S, 2 + Len(CDSI) + 2, InStr(1 + Len(CDSI) + 2, S, ")") - 2 - Len(CDSI) - 2)
IPAD = Mid(S, InStr(1, S, ".(") + 2, InStr(1, S, ").xls") - InStr(1, S, ".(") - 2)
Application.ScreenUpdating = False
Workbooks.OpenText Filename:= _
"http://" + IPAD + "/CleanGreen/Health?XLSR=1&RVID=" + RVID + "&CDSI=" + CDSI, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
, Comma:=True, Space:=False, Other:=False
Call Format(CDSI)
Sheets(1).Name = "HealthChart"
Application.ScreenUpdating = True
End Sub
-
RE: Star Office sales compared to MSFT Office sales
2003-02-01 02:36:57 anonymous2 [Reply | View]
Most people do not buy MS Office from Amazon. They buy it with their computers. Giants like Dell offer MS Office as a customizable option with their computers.
Perhaps we get a better picture if we have more data.
-
How about doing one on word format
2003-01-30 07:34:49 malcolmd [Reply | View]
Great Article. It's just the sort of stuff I need for a project I will be working on in a little while.
I've downloaded all the latest poi stuff from the web site (Source for the latest sutff was a bit tricky to find)
I look forward to the article on actually reading the details of the workbook from the excel file.
Suggestions for future articles:
How to read and write Word files
How to read and write the document Summary information
-
Star Office sales compared to MSFT Office sales
2003-01-29 09:19:23 anonymous2 [Reply | View]
taking a look at Amazon.com's software sales:
Star Office
Price: $ 65.95
Platforms: Linux, Sun Solaris, Windows 95 / 98 / NT / 2000 / Me / XP
Sales Rank: 140
Rating: 4.5 stars
Microsoft Office XP Professional
Price: $ 446.99
Platforms: Windows 98 / NT / 2000 / Me / XP
Sales Rank: 807
Rating: 3 stars
I know this isn't a scientific study, etc. but something is happening.
-
How do I output to Excel using POI
2003-01-28 21:51:47 aviks [Reply | View]
Well, this is meant to be a three part series, and the first part just talks about the underlying filesystem code, on top of which sits the more high level code. If you are impatient, look up the POI web pages at http://jakarta.apache.org/poi, in particular http://jakarta.apache.org/poi/hssf/quick-guide.html.
-
How do I output to Excel using POI
2003-01-28 13:36:01 anonymous2 [Reply | View]
I read the above and I think I get it, but I don't understand how it helps me output to Excel...
-
alternatives to windows office tools
2003-01-28 11:23:29 anonymous2 [Reply | View]
Let's get real. We are in the "nobody ever gets fired for suggesting Word" world. Interfaces are good, we may use alternatives (I do Linux rules!) but the clients can spell Word and Excel period.
FWIW
jimB
-
porting proprietary formats supports proprietary formats
2003-01-25 17:08:37 anonymous2 [Reply | View]
The last poster whines about clients owning Office. Thats why its our job to educate them. Tell them "I understand you own serveral licenses of Office, to support the kind of software you want us to write we need to upgrade it to OpenOffice. The best thing is that it won't cost you anything." By doing this you move your client to a better piece of software that frees them from paying for license upgrades every 2 years. Next, you do your part to end these formats. See this: http://www.gnu.org/philosophy/no-word-attachments.html for more information on how you can help. Write the authors of this article and of the POI library and explain to them how misguided they are. -
porting proprietary formats supports proprietary formats
2003-04-22 04:30:34 anonymous2 [Reply | View]
Programmers should NOT try to evangalise their clients into using something they feel is pure.
They should take the specs and write the code.
If there is a technical reason why that code can't be created, THEN you may go to the client and tell him so, but never because you're too lazy or you think you're too good to do it.
If you're going to tell a multinational they need to change their entire IT infrastructure just because you feel deep inside that Microsoft is evil you'll be fired from the job there and then and rightly so.
MS Office is the de-facto standard in office application fileformats out there, so you'd better live with it.
Even IF you get your employer to move to another office package, a major requirement of that package will be support for MS Office files because they will get those files from outside sources all the time and will need to read them (and write them, as they can't expect their contacts to have some obscure package that you're using because it's properly anti-Microsoft).
-
Welcome to the real world
2003-01-25 01:19:37 anonymous2 [Reply | View]
How wonderful it must be to be the person that posted the previous comment. I wish that sort of myopic attitude actually worked.
Client: We need the program to write that information out in (Word, Excel, whatever) format.
Designer: How about we do this instead? We'll remove Microsoft Office from all of your machines and install OpenOffice.org instead.
Client: OpenOffice.what?
Designer: OpenOffice.org. It's an open source office suite. It's free.
Client: But we already own Microsoft Office...
Designer: Yes, but the file format is so lousy.
At which point you get either a blank look or fired, one of the two. Pinhead.





this is nanda Kishore. i need a code to change *.xls to *.csv.
pls help me. i writed so many ways but it is not working pls send code