Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2005

Tip: Looking for answers? Try searching our database.

Saving HSSFCellStyle in Excel file

Thread view: 
Ghislain Benrais - 28 Sep 2005 18:27 GMT
Hi world,
   I'm writing excel files with HSSF libraries and it works very well.
Nevertheless, I think I have misunderstood something about HSSF styles. I'm
afraid they're only available when java is running. Or is it possible to
save them in the excel result, with a nice name, so that the excel user can
modify the applied style ? If could there be a workaround ?
Here is a sample program :

   HSSFWorkbook wb = new HSSFWorkbook();    HSSFSheet sheet =
wb.createSheet("new sheet");    HSSFRow row = sheet.createRow((short)0);
HSSFCell cell = row.createCell((short)0);    cell.setCellValue(1);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderBottom(cellStyle.BORDER_THICK);    cell =
row.createCell((short)0);    cell.setCellValue(1);
cell.setCellStyle(cellStyle);    FileOutputStream fileOut = new
FileOutputStream("workbook.xls");    wb.write(fileOut);
fileOut.close();workbook.xls contains a cell with the expected formatting
properties, but its style is 'normal'.Thanks,Ghislain
Massimo Dell'Andrea - 29 Sep 2005 10:58 GMT
> Hi world,
>     I'm writing excel files with HSSF libraries and it works very well.
[quoted text clipped - 14 lines]
> fileOut.close();workbook.xls contains a cell with the expected formatting
> properties, but its style is 'normal'.Thanks,Ghislain

Try using HSSFCellStyle.BORDER_THIN
Ghislain Benrais - 29 Sep 2005 11:22 GMT
Thanks Massimo but the program works ! I get the border I expected. The
trouble is that the cell doesn't have its own style. So suppose I have
thousands of cells with this style, how could the excel user change its
formatting properties.
>> Hi world,
>>     I'm writing excel files with HSSF libraries and it works very well.
[quoted text clipped - 16 lines]
>
> Try using HSSFCellStyle.BORDER_THIN
Ghislain Benrais - 30 Sep 2005 10:56 GMT
Well, I'm afraid it's not possible to retrieve styles according to :
http://issues.apache.org/bugzilla/show_bug.cgi?id=35498


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.