2009-08-18 15:49:28 -04:00
|
|
|
/* ====================================================================
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
|
|
|
|
2006-12-22 15:56:04 -05:00
|
|
|
package org.apache.poi.hssf.usermodel;
|
|
|
|
|
|
|
|
import junit.framework.TestCase;
|
2009-03-29 12:10:40 -04:00
|
|
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
2006-12-22 15:56:04 -05:00
|
|
|
|
2009-08-18 15:49:28 -04:00
|
|
|
public final class TestUnicodeWorkbook extends TestCase {
|
2006-12-22 15:56:04 -05:00
|
|
|
|
2009-08-18 15:49:28 -04:00
|
|
|
/**
|
|
|
|
* Tests Bug38230
|
2006-12-22 15:56:04 -05:00
|
|
|
* That a Umlat is written and then read back.
|
|
|
|
* It should have been written as a compressed unicode.
|
|
|
|
*/
|
2009-08-18 15:49:28 -04:00
|
|
|
public void testUmlatReadWrite() {
|
2006-12-22 15:56:04 -05:00
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
2009-03-29 12:10:40 -04:00
|
|
|
|
2006-12-22 15:56:04 -05:00
|
|
|
//Create a unicode sheet name (euro symbol)
|
|
|
|
HSSFSheet s = wb.createSheet("test");
|
2009-03-29 12:10:40 -04:00
|
|
|
|
2006-12-22 15:56:04 -05:00
|
|
|
HSSFRow r = s.createRow(0);
|
2008-08-25 18:41:08 -04:00
|
|
|
HSSFCell c = r.createCell(1);
|
2006-12-22 15:56:04 -05:00
|
|
|
c.setCellValue(new HSSFRichTextString("\u00e4"));
|
2009-03-29 12:10:40 -04:00
|
|
|
|
2006-12-22 15:56:04 -05:00
|
|
|
//Confirm that the sring will be compressed
|
|
|
|
assertEquals(c.getRichStringCellValue().getUnicodeString().getOptionFlags(), 0);
|
2009-03-29 12:10:40 -04:00
|
|
|
|
|
|
|
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
2006-12-22 15:56:04 -05:00
|
|
|
|
|
|
|
//Test the sheetname
|
|
|
|
s = wb.getSheet("test");
|
|
|
|
assertNotNull(s);
|
2009-03-29 12:10:40 -04:00
|
|
|
|
2008-08-25 18:41:08 -04:00
|
|
|
c = r.getCell(1);
|
2006-12-22 15:56:04 -05:00
|
|
|
assertEquals(c.getRichStringCellValue().getString(), "\u00e4");
|
2009-03-29 12:10:40 -04:00
|
|
|
}
|
2006-12-22 15:56:04 -05:00
|
|
|
}
|