poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 40039] New: - Excel file repaired after being created
Date Thu, 13 Jul 2006 17:12:41 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40039>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40039

           Summary: Excel file repaired after being created
           Product: POI
           Version: unspecified
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: xpto2k3@gmail.com
                CC: xpto2k3@gmail.com


Using version poi-2.5.1-final-20040804, i tried writing an Excel file from a web
dynpro SAP component. When downloading to local pc, Excel opens the file by
repairing it. In the "show repairs" option of Excel, i got this:

"Damage to the file was so extensive that repairs were not possible. Excel
attempted to recover your formulas and values, but some data may have been lost
or corrupted."

The final sheet appears with one less column than i wanted. And what i want is
very simple: a sheet with a first row filled and first column filled with a
string code, second line with 10 columns with strings (headers), and then a
dynamic number of rows filling the first column with an integer value. 

Here's the code i use:

  public byte[] exportToExcel( )
  {
    //@@begin exportToExcel()

	  //Create a workbook
	  HSSFWorkbook wb = new HSSFWorkbook();

	  //Create an sheet attached to the workbook
	  HSSFSheet sheet = wb.createSheet("Form Valores Levantamento");

	  // Create a row (first header)
	  HSSFRow row = sheet.createRow((short) 0);
	  wdContext.currentResultadosElement().getCodigo();
	  row.createCell((short) 0).setCellValue("Levantamento Nº");
	  row.createCell((short)
1).setCellValue(wdContext.currentResultadosElement().getCodigo());

	  // Create a row (second header)
	  row = sheet.createRow((short) 1);
	  // Create all cells and put all value in it.
	  row.createCell((short) 0).setCellValue("Código");
	  row.createCell((short) 1).setCellValue("Quantidade Último Ano");
	  row.createCell((short) 2).setCellValue("Prazo Médio Entrega");
	  row.createCell((short) 3).setCellValue("Data Última Aquisição");
	  row.createCell((short) 4).setCellValue("Quantidade Última Aquisição");
	  row.createCell((short) 5).setCellValue("Custo Unitário");
	  row.createCell((short) 6).setCellValue("Prev. Min. Mensal");
	  row.createCell((short) 7).setCellValue("Prev. Min. Anual");
	  row.createCell((short) 8).setCellValue("Prev. Max. Mensal");
	  row.createCell((short) 9).setCellValue("Prev. Max. Anual");
	 
	  	  
	  int count = wdContext.nodeNecValores_excel().size();
	  
	  for (int i = 0; i < count; i++){
		
		  IPublicLevValores.INecValores_excelElement elem=
			  wdContext.nodeNecValores_excel().getNecValores_excelElementAt(i);
		
		  double prod_id = Double.parseDouble( (elem.getProd_id()).trim() );
		
		  //Create a row 
		  row = sheet.createRow((short) i+2);
		  // Create all cells and put all value in it.
		  row.createCell((short) 0).setCellValue(prod_id);
	  }
	  
	//	get attribute info for context attribute 'FileResource'
	IWDAttributeInfo attributeInfo =
	wdContext.getNodeInfo().getAttribute(IPublicLevValores.IContextElement.FILE_RESOURCE);
	//	create a modifiable binary type for the context attribute
	//	which stores the MIME-object.

	IWDModifiableBinaryType binaryType =
	(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();  
 	
	wdContext.currentContextElement().setFileResource(wb.getBytes());

	binaryType.setFileName("folha-levantamentos.xls");
	binaryType.setMimeType(WDWebResourceType.XLS);	  

	return wb.getBytes();
	
    //@@end
  }



The cell created by this line:
row.createCell((short) 9).setCellValue("Prev. Max. Anual");
never appears on the final Excel.

I allready tried changing POI versions to older versions, but the problem
maintains. Even worse, besides the "Corrupt file" messages, i loose one of the
rows now.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message