I spent time on the Internet researching how to build a new Excel spreadsheet from Java and I found several different API's for doing it. Some of them were free; some of them were not free. I spent several hours learning one of the free API's and experimenting on creating simple Excel spreadsheets with basic cell formatting (borders, background colors, differing fonts, etc).
It was only after all this that I was talking to a co-worker who had a better suggestion for me. Since I didn't need to do anything fancy in the spreadsheet, I really only needed to format daily production numbers into a easy to view format, he suggested that I build an html page and import it into Excel. He explained that if I created an html page with a simple HTML table, change the name to end with .xls (the default Excel file extension), and then open the document in Excel, it would display correctly.
So I tried it and it worked. Since I had to build the HTML table anyways for the web page, I just had to create the code to save the page as the Excel document and attach it to an email. All of the formatting was saved and the page displayed perfectly. No complicated api's were needed and hardly any extra code was needed. Try it yourself. Once you save the file (use testing.xls), double-click and watch it open in excel with the table preserved. For my real world project, I have css formatting built into the top of the document and it transfers right across to the excel document.
There are a couple of caveats to watch out for when using this method to create Excel files. First and foremost, this is only for simple Excel spreadsheets that are for displaying data only. This method will not work for any applications that need to do mathematical functions or anything like that. You need to explore the native api's to do the complicated stuff. Another warning, do not use an external CSS file as it won't be imported and the formatting will be lost. If the formatting is lost, then the document will not look correctly.
I hope this simple tip helps save you some time on your simple Excel spreadsheets.
Published by smglo2006
Father of 3 strapping boys with lots of advice of what not to do. View profile
How to Optimize that Older Windows Computer - Without Upgrading to a New...These guidelines intend to show you how to optimize an older desktop PC without going hog wild on cost, and preferably using existing older equipment. - How to Write a Good ResumeAn in-depth explanation on how to write a good resume, section by section.
- How to Make an HTML TableHere are the steps to making a basic HTML table.
- How to Find Information on an Excel Spreadsheet It's easy to find information on an Excel spreadsheet once you know what you are looking for and how to sort the spreadsheet in a way that groups data together. I can now sort it to group specific types of information...
- How to Create an Excel Spreadsheet Online to Share Using Google Docs
- Creating Active Hyperlinks in Microsoft Excel
- Introduction to Microsoft Excel
- Convert Excel Data to Comma Separated Text
- Step-by-Step Microsoft Excel Tutorial for Beginners
- Creating Labels in Word 2007: Mail Merge Using Data from Excel
- Google Spreadsheets: The Online Collaboration Tool from Google

1 Comments
Post a Commentcan you give an example because i can't seem to understand it..thank you