poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Danilo Marques de Rezende <danilom...@gmail.com>
Subject Fwd: Protectsheet excel 2003 read problem
Date Mon, 14 Mar 2011 19:50:56 GMT
Hi,
I'm having some trouble with the "Locking" e "Protecting" sheet from POI,
I'm generating an excel file with the following code:

Workbook workbook = new HSSFWorkbook()
Sheet sheet = workbook.createSheet("test")
//Create a lot of rows and cells like the following, merge regions, format
styles like fonts and colors
sheet.createRow(0).createCell(0).setCellValue("test")
//them set some cells as locked using the CellStyle like the following
CellStyle styleOne = workbook.createCellStyle()
styleOne.setLocked(true)
 Iterator rowIterator = sheet.rowIterator()
while(rowIterator.hasNext()){
    Row row = rowIterator.next()
    row.getCell(3).setCellStyle(styleOne)
    row.getCell(4).setCellStyle(styleOne)
}
sheet.protectSheet("myPassword")

FileOutputStream stream = new FileOutputStream(completePath)
workbook.write(stream)
stream.flush()
stream.close()

/////////////////////////
Actualy it works when I open the workbook using the microsoft Office 2007 or
above versions or
using OpenOffice calc, but I try to open it using the Microsoft excel 2003
it gives some error
messages like these:(I'm translating it because I use a protuguese version
of Microsoft Office)
"There are too much different cell formats" and "The Microsoft excel found
an error and had to remove
some formating to avoid corruption of the workbook. Verify again the
formatting carefully."


Any idea of how to solve it?
Is that a bug?


-- 
Att.
Danilo Marques

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message