Package org.apache.poi.hssf.record.common

Examples of org.apache.poi.hssf.record.common.UnicodeString


                    lrec.setRow(row);
                    lrec.setXFIndex(styleIndex);
                }
                if (setValue) {
                    String str = convertCellValueToString();
                    int sstIndex = _book.getWorkbook().addSSTString(new UnicodeString(str));
                    lrec.setSSTIndex(sstIndex);
                    UnicodeString us = _book.getWorkbook().getSSTString(sstIndex);
                    _stringValue = new HSSFRichTextString();
                    _stringValue.setUnicodeString(us);
                }
                _record = lrec;
                break;
View Full Code Here


        if (_cellType != CELL_TYPE_STRING) {
            setCellType(CELL_TYPE_STRING, false, row, col, styleIndex);
        }
        int index = 0;

        UnicodeString str = hvalue.getUnicodeString();
        index = _book.getWorkbook().addSSTString(str);
        (( LabelSSTRecord ) _record).setSSTIndex(index);
        _stringValue = hvalue;
        _stringValue.setWorkbookReferences(_book.getWorkbook(), (( LabelSSTRecord ) _record));
        _stringValue.setUnicodeString(_book.getWorkbook().getSSTString(index));
View Full Code Here

    public void test47847() throws Exception {
       HSSFWorkbook wb = openSample("47847.xls");
       assertEquals(3, wb.getNumberOfSheets());
      
       // Find the SST record
       UnicodeString withExt = wb.getWorkbook().getSSTString(0);
       UnicodeString withoutExt = wb.getWorkbook().getSSTString(31);
      
       assertEquals("O:Alloc:Qty", withExt.getString());
       assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
      
       assertEquals("RT", withoutExt.getString());
       assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
      
       // Something about continues...

      
       // Write out and re-read
       wb = writeOutAndReadBack(wb);
       assertEquals(3, wb.getNumberOfSheets());
      
       // Check it's the same now
       withExt = wb.getWorkbook().getSSTString(0);
       withoutExt = wb.getWorkbook().getSSTString(31);
      
       assertEquals("O:Alloc:Qty", withExt.getString());
       assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
      
       assertEquals("RT", withoutExt.getString());
       assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
    }
View Full Code Here

                    lrec.setRow(row);
                    lrec.setXFIndex(styleIndex);
                }
                if (setValue) {
                    String str = convertCellValueToString();
                    int sstIndex = _book.getWorkbook().addSSTString(new UnicodeString(str));
                    lrec.setSSTIndex(sstIndex);
                    UnicodeString us = _book.getWorkbook().getSSTString(sstIndex);
                    _stringValue = new HSSFRichTextString();
                    _stringValue.setUnicodeString(us);
                }
                _record = lrec;
                break;
View Full Code Here

        if (_cellType != CELL_TYPE_STRING) {
            setCellType(CELL_TYPE_STRING, false, row, col, styleIndex);
        }
        int index = 0;

        UnicodeString str = hvalue.getUnicodeString();
        index = _book.getWorkbook().addSSTString(str);
        (( LabelSSTRecord ) _record).setSSTIndex(index);
        _stringValue = hvalue;
        _stringValue.setWorkbookReferences(_book.getWorkbook(), (( LabelSSTRecord ) _record));
        _stringValue.setUnicodeString(_book.getWorkbook().getSSTString(index));
View Full Code Here

                 LabelRecord oldrec = ( LabelRecord ) rec;

                 records.remove(k);
                 LabelSSTRecord newrec   = new LabelSSTRecord();
                 int            stringid =
                     workbook.addSSTString(new UnicodeString(oldrec.getValue()));

                 newrec.setRow(oldrec.getRow());
                 newrec.setColumn(oldrec.getColumn());
                 newrec.setXFIndex(oldrec.getXFIndex());
                 newrec.setSSTIndex(stringid);
View Full Code Here

    /** @deprecated Do not call this method from your applications. Use the methods
     *  available in the HSSFRow to add string HSSFCells
     */
    public int addSSTString(String string)
    {
        return workbook.addSSTString(new UnicodeString(string));
    }
View Full Code Here

    public void test47847() throws Exception {
       HSSFWorkbook wb = openSample("47847.xls");
       assertEquals(3, wb.getNumberOfSheets());
      
       // Find the SST record
       UnicodeString withExt = wb.getWorkbook().getSSTString(0);
       UnicodeString withoutExt = wb.getWorkbook().getSSTString(31);
      
       assertEquals("O:Alloc:Qty", withExt.getString());
       assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
      
       assertEquals("RT", withoutExt.getString());
       assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
      
       // Something about continues...

      
       // Write out and re-read
       wb = writeOutAndReadBack(wb);
       assertEquals(3, wb.getNumberOfSheets());
      
       // Check it's the same now
       withExt = wb.getWorkbook().getSSTString(0);
       withoutExt = wb.getWorkbook().getSSTString(31);
      
       assertEquals("O:Alloc:Qty", withExt.getString());
       assertTrue((withExt.getOptionFlags() & 0x0004) == 0x0004);
      
       assertEquals("RT", withoutExt.getString());
       assertTrue((withoutExt.getOptionFlags() & 0x0004) == 0x0000);
    }
View Full Code Here

        int total_length = 0;

        for ( int k = 0; k < bstrings.length; k++ )
        {
            Arrays.fill( bstrings[k], (byte) ( 'a' + k ) );
            strings[k] = new UnicodeString( new String(bstrings[k]) );
            record.addString( strings[k] );
            total_length += 3 + bstrings[k].length;
        }

        // add overhead of SST record
        total_length += 8;

        // add overhead of broken strings
        total_length += 4;

        // add overhead of six records
        total_length += ( 6 * 4 );
        byte[] content = new byte[record.getRecordSize()];

        record.serialize( 0, content );
        assertEquals( total_length, content.length );

        //Deserialize the record.
        RecordInputStream recStream = new RecordInputStream(new ByteArrayInputStream(content));
        recStream.nextRecord();
        record = new SSTRecord(recStream);

        assertEquals( strings.length, record.getNumStrings() );
        assertEquals( strings.length, record.getNumUniqueStrings() );
        assertEquals( strings.length, record.countStrings() );
        for ( int k = 0; k < strings.length; k++ )
        {
            assertEquals( strings[k], record.getString( k ) );
        }
        record = new SSTRecord();
        bstrings[1] = new byte[bstrings[1].length - 1];
        for ( int k = 0; k < bstrings.length; k++ )
        {
            if ( ( bstrings[k].length % 2 ) == 1 )
            {
                Arrays.fill( bstrings[k], (byte) ( 'a' + k ) );
                strings[k] = new UnicodeString( new String(bstrings[k]) );
            }
            else
            {
                char[] data = new char[bstrings[k].length / 2];

                Arrays.fill( data, (char) ( '\u2122' + k ) );
                strings[k] = new UnicodeString(new String( data ));
            }
            record.addString( strings[k] );
        }
        content = new byte[record.getRecordSize()];
        record.serialize( 0, content );
View Full Code Here

        SSTRecord record = new SSTRecord();

        // the record will start with two integers, then this string
        // ... that will eat up 16 of the 8224 bytes that the record
        // can hold
        record.addString( new UnicodeString("Hello") );

        // now we have an additional 8208 bytes, which is an exact
        // multiple of 16 bytes
        long testvalue = 1000000000000L;

        for ( int k = 0; k < 2000; k++ )
        {
            record.addString( new UnicodeString(String.valueOf( testvalue++ )) );
        }
        byte[] content = new byte[record.getRecordSize()];

        record.serialize( 0, content );
        assertEquals(8224, LittleEndian.getShort(content, 2));
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.common.UnicodeString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.