Bug 12899 - (RFE: Unicode Custom Number formats. ) Corrupted, but readable excel file is generated. Excel displays "File error. Some number formats may have been lost." on open.
Summary: (RFE: Unicode Custom Number formats. ) Corrupted, but readable excel file is ...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-dev
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-22 06:50 UTC by Victor Arabadjiyski
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments
Template file (15.00 KB, application/octet-stream)
2002-09-22 10:59 UTC, Victor Arabadjiyski
Details
Generated Excel file (corrupted) (7.50 KB, application/octet-stream)
2002-09-22 11:02 UTC, Victor Arabadjiyski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Arabadjiyski 2002-09-22 06:50:10 UTC
Hi,
I tried to generate excel file from template. When opening generated file with 
Excel (2002) it displayed the message: "File error. Some number formats may 
have been lost.".

Here are the files:
 - template file (http://www.geocities.com/et_victor/template.xls)
 - generated file (http://www.geocities.com/et_victor/result.xls)
 
The source of a generator program follows:
import java.io.*;
import java.util.*;
import java.sql.*;

import beans.common.*;
import beans.customers.*;

import util.transfer.*;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.*;

public class ExcelGenerator
{
 private static void generate(File objTemplate, File objTarget) throws Exception
 {
  //open
  FileInputStream fis = new FileInputStream(objTemplate);
  POIFSFileSystem fs = new POIFSFileSystem(fis);
  HSSFWorkbook wb = new HSSFWorkbook(fs);
  fis.close();

  FileOutputStream fileOut = new FileOutputStream(objTarget);
  wb.write(fileOut);
  fileOut.close();
 }

 public static void main(String[] args)
 {
  try
  {
   File objTemplate = new File("c:/temp/template.xls");
   File objTarget = new File("c:/temp/result.xls");
   generate(objTemplate, objTarget);
  }catch (Exception ex)
  {
   ex.printStackTrace();
  }
 }
}
Comment 1 Victor Arabadjiyski 2002-09-22 10:59:37 UTC
Created attachment 3165 [details]
Template file
Comment 2 Victor Arabadjiyski 2002-09-22 11:02:40 UTC
Created attachment 3166 [details]
Generated Excel file (corrupted)
Comment 3 Andy Oliver 2002-09-22 16:58:32 UTC
There are what I presume is an extended character in the custom number formats
saved in the file.  I bet HSSF is trying to render them as 8-bit ("compressed
unicode") strings.  That of course is not going to work.

Since this area has been recently enhanced please try this with the 1.8
development release and report back.
Comment 4 Victor Arabadjiyski 2002-09-22 20:04:36 UTC
Success!
Development release 1.8 fixes this.
Generated Excel file is read without any problems or error messages.
Good work, guys!
Comment 5 Andy Oliver 2002-09-23 00:25:39 UTC
Excellent.  Because this is a 2.0 feature, I'm marking it fixed in the 2.0-dev
series.  This feature won't be backported to 1.5.x.