You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Alain Mowat <am...@bluewin.ch> on 2006/12/08 17:49:33 UTC

Problems with HSSF and character sets

    Hello,
    I'm having problems using HSSF with czech files, and probably other languages that have special characters in them. 
    If I open a file, and then simply write this same file to the hard disk with no modification whatsoever, the saving process actually modifies a certain number of characters and replaces them by a '?'. 
    This happens with the following simple code : 
        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Path to file"));

        wb = new HSSFWorkbook(fs);

        FileOutputStream fileOut = new FileOutputStream("Some location");

        wb.write(fileOut);


    Strangely, not all characters are altered. For example, the word  "nebezpecná" becomes "nebezpe?ná" in one cell, but no modification is done to the same word in the following cell.

    It appears to come from the way the file is saved to the disk. Maybe POI saves the file as an old Excel 95 file, the same problem seems to happen when this is done directly in Excel.

    Does anybody know how I can stop these alteration from happening?

    Thanks,

    Alain 

Re: Problems with HSSF and character sets

Posted by Alain Mowat <am...@bluewin.ch>.
Thanks for the answer, unfortunately, I'm already using the RichTextStrings.
And the problem is it modifies the values in some fields that I don't even
touch. Just by saving a file I just opened introduces these errors...

Alain
----- Original Message ----- 
From: "Vincent" <vi...@gmail.com>
To: "POI Users List" <po...@jakarta.apache.org>
Sent: Tuesday, January 09, 2007 2:29 PM
Subject: Re: Problems with HSSF and character sets


> Maybe you should try HSSFRichTextString. I have also using verison 3.0
> alpha 3 , not met the problem you mentioned.
>
> setCellValue
>
> public void setCellValue(HSSFRichTextString value)
>
>     set a string value for the cell. Please note that if you are using
> full 16 bit unicode you should call setEncoding() first.
>
>     Parameters:
>         value - value to set the cell to. For formulas we'll set the
> formula string, for String cells we'll set its value. For other types
> we will change the cell to a string cell and set its value. If value
> is null then we will change the cell to a Blank cell.
>
> On 1/8/07, Alain Mowat <am...@bluewin.ch> wrote:
> >     I forgot to mention that I am using the version 3.0 alpha3. So it
should
> > be using unicode all the time. And in the code I posted below I don't
even
> > copy the content of the cells, I just save the file elsewhere on my
system.
> >
> >     Any more help?
> >
> >     Alain
> > ----- Original Message -----
> > From: "Andrew C. Oliver" <ac...@apache.org>
> > To: "POI Users List" <po...@jakarta.apache.org>
> > Sent: Saturday, December 09, 2006 10:59 AM
> > Subject: Re: Problems with HSSF and character sets
> >
> >
> > > http://jakarta.apache.org/poi/faq.html#faq-N100A4  FAQ #11.
> > >
> > > -andy
> > >
> > > Alain Mowat wrote:
> > > >     Hello,
> > > >     I'm having problems using HSSF with czech files, and probably
other
> > languages that have special characters in them.
> > > >     If I open a file, and then simply write this same file to the
hard
> > disk with no modification whatsoever, the saving process actually
modifies a
> > certain number of characters and replaces them by a '?'.
> > > >     This happens with the following simple code :
> > > >         POIFSFileSystem fs = new POIFSFileSystem(new
> > FileInputStream("Path to file"));
> > > >
> > > >         wb = new HSSFWorkbook(fs);
> > > >
> > > >         FileOutputStream fileOut = new FileOutputStream("Some
> > location");
> > > >
> > > >         wb.write(fileOut);
> > > >
> > > >
> > > >     Strangely, not all characters are altered. For example, the word
> > "nebezpecná" becomes "nebezpe?ná" in one cell, but no modification is
done
> > to the same word in the following cell.
> > > >
> > > >     It appears to come from the way the file is saved to the disk.
Maybe
> > POI saves the file as an old Excel 95 file, the same problem seems to
happen
> > when this is done directly in Excel.
> > > >
> > > >     Does anybody know how I can stop these alteration from
happening?
> > > >
> > > >     Thanks,
> > > >
> > > >     Alain
> > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > > The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> >
> >
>


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


Re: Problems with HSSF and character sets

Posted by Vincent <vi...@gmail.com>.
Maybe you should try HSSFRichTextString. I have also using verison 3.0
alpha 3 , not met the problem you mentioned.

setCellValue

public void setCellValue(HSSFRichTextString value)

    set a string value for the cell. Please note that if you are using
full 16 bit unicode you should call setEncoding() first.

    Parameters:
        value - value to set the cell to. For formulas we'll set the
formula string, for String cells we'll set its value. For other types
we will change the cell to a string cell and set its value. If value
is null then we will change the cell to a Blank cell.

On 1/8/07, Alain Mowat <am...@bluewin.ch> wrote:
>     I forgot to mention that I am using the version 3.0 alpha3. So it should
> be using unicode all the time. And in the code I posted below I don't even
> copy the content of the cells, I just save the file elsewhere on my system.
>
>     Any more help?
>
>     Alain
> ----- Original Message -----
> From: "Andrew C. Oliver" <ac...@apache.org>
> To: "POI Users List" <po...@jakarta.apache.org>
> Sent: Saturday, December 09, 2006 10:59 AM
> Subject: Re: Problems with HSSF and character sets
>
>
> > http://jakarta.apache.org/poi/faq.html#faq-N100A4  FAQ #11.
> >
> > -andy
> >
> > Alain Mowat wrote:
> > >     Hello,
> > >     I'm having problems using HSSF with czech files, and probably other
> languages that have special characters in them.
> > >     If I open a file, and then simply write this same file to the hard
> disk with no modification whatsoever, the saving process actually modifies a
> certain number of characters and replaces them by a '?'.
> > >     This happens with the following simple code :
> > >         POIFSFileSystem fs = new POIFSFileSystem(new
> FileInputStream("Path to file"));
> > >
> > >         wb = new HSSFWorkbook(fs);
> > >
> > >         FileOutputStream fileOut = new FileOutputStream("Some
> location");
> > >
> > >         wb.write(fileOut);
> > >
> > >
> > >     Strangely, not all characters are altered. For example, the word
> "nebezpecná" becomes "nebezpe?ná" in one cell, but no modification is done
> to the same word in the following cell.
> > >
> > >     It appears to come from the way the file is saved to the disk. Maybe
> POI saves the file as an old Excel 95 file, the same problem seems to happen
> when this is done directly in Excel.
> > >
> > >     Does anybody know how I can stop these alteration from happening?
> > >
> > >     Thanks,
> > >
> > >     Alain
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> > The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>
>

Re: Problems with HSSF and character sets

Posted by Alain Mowat <am...@bluewin.ch>.
    I forgot to mention that I am using the version 3.0 alpha3. So it should
be using unicode all the time. And in the code I posted below I don't even
copy the content of the cells, I just save the file elsewhere on my system.

    Any more help?

    Alain
----- Original Message ----- 
From: "Andrew C. Oliver" <ac...@apache.org>
To: "POI Users List" <po...@jakarta.apache.org>
Sent: Saturday, December 09, 2006 10:59 AM
Subject: Re: Problems with HSSF and character sets


> http://jakarta.apache.org/poi/faq.html#faq-N100A4  FAQ #11.
>
> -andy
>
> Alain Mowat wrote:
> >     Hello,
> >     I'm having problems using HSSF with czech files, and probably other
languages that have special characters in them.
> >     If I open a file, and then simply write this same file to the hard
disk with no modification whatsoever, the saving process actually modifies a
certain number of characters and replaces them by a '?'.
> >     This happens with the following simple code :
> >         POIFSFileSystem fs = new POIFSFileSystem(new
FileInputStream("Path to file"));
> >
> >         wb = new HSSFWorkbook(fs);
> >
> >         FileOutputStream fileOut = new FileOutputStream("Some
location");
> >
> >         wb.write(fileOut);
> >
> >
> >     Strangely, not all characters are altered. For example, the word
"nebezpecná" becomes "nebezpe?ná" in one cell, but no modification is done
to the same word in the following cell.
> >
> >     It appears to come from the way the file is saved to the disk. Maybe
POI saves the file as an old Excel 95 file, the same problem seems to happen
when this is done directly in Excel.
> >
> >     Does anybody know how I can stop these alteration from happening?
> >
> >     Thanks,
> >
> >     Alain
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>


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


Re: Problems with HSSF and character sets

Posted by "Andrew C. Oliver" <ac...@apache.org>.
http://jakarta.apache.org/poi/faq.html#faq-N100A4  FAQ #11.

-andy

Alain Mowat wrote:
>     Hello,
>     I'm having problems using HSSF with czech files, and probably other languages that have special characters in them. 
>     If I open a file, and then simply write this same file to the hard disk with no modification whatsoever, the saving process actually modifies a certain number of characters and replaces them by a '?'. 
>     This happens with the following simple code : 
>         POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Path to file"));
>
>         wb = new HSSFWorkbook(fs);
>
>         FileOutputStream fileOut = new FileOutputStream("Some location");
>
>         wb.write(fileOut);
>
>
>     Strangely, not all characters are altered. For example, the word  "nebezpecná" becomes "nebezpe?ná" in one cell, but no modification is done to the same word in the following cell.
>
>     It appears to come from the way the file is saved to the disk. Maybe POI saves the file as an old Excel 95 file, the same problem seems to happen when this is done directly in Excel.
>
>     Does anybody know how I can stop these alteration from happening?
>
>     Thanks,
>
>     Alain 
>   



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