Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657578 via svnmerge from
https://svn.apache.org:443/repos/asf/poi/trunk ........ r657166 | josh | 2008-05-16 19:46:04 +0100 (Fri, 16 May 2008) | 1 line Simplification of BiffViewer. Made easier to send results to file. ........ r657167 | josh | 2008-05-16 19:55:02 +0100 (Fri, 16 May 2008) | 1 line Fix for bug 40414 - update selected/active sheet after removing sheet from workbook ........ r657180 | josh | 2008-05-16 20:24:47 +0100 (Fri, 16 May 2008) | 1 line fixed bug number in junit msg - from r656893 bug 44523 ........ r657355 | yegor | 2008-05-17 15:00:30 +0100 (Sat, 17 May 2008) | 1 line added HSSFName.isDeleted() to check if the name points to cell that no longer exists ........ r657358 | yegor | 2008-05-17 15:03:27 +0100 (Sat, 17 May 2008) | 1 line misc bug fixes ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@657579 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a023da88d0
commit
937d2700ed
@ -44,6 +44,8 @@
|
|||||||
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="3.1-beta2" date="2008-05-??">
|
<release version="3.1-beta2" date="2008-05-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted() to check if the name points to cell that no longer exists</action>
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">40414 - fixed selected/active sheet after removing sheet from workbook</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection and focus</action>
|
<action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection and focus</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when numberText is null</action>
|
<action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when numberText is null</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
|
<action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
|
||||||
|
@ -1284,6 +1284,20 @@ Examples:
|
|||||||
Cell c = r.getCell(crefs[j].getCol());
|
Cell c = r.getCell(crefs[j].getCol());
|
||||||
// Do something with this corner cell
|
// Do something with this corner cell
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
</source>
|
||||||
|
<p>
|
||||||
|
Note, when a cell is deleted, Excel does not delete the
|
||||||
|
attached named range. As result, workbook can contain
|
||||||
|
named ranges that point to cells that no longer exist.
|
||||||
|
You should check the validity of a reference before
|
||||||
|
constructing AreaReference
|
||||||
|
</p>
|
||||||
|
<source>
|
||||||
|
if(hssfName.isDeleted()){
|
||||||
|
//named range points to a deleted cell.
|
||||||
|
} else {
|
||||||
|
AreaReference ref = new AreaReference(hssfName.getReference());
|
||||||
}
|
}
|
||||||
</source>
|
</source>
|
||||||
</section>
|
</section>
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
<action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="3.1-beta2" date="2008-05-??">
|
<release version="3.1-beta2" date="2008-05-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted() to check if the name points to cell that no longer exists</action>
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">40414 - fixed selected/active sheet after removing sheet from workbook</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection and focus</action>
|
<action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection and focus</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when numberText is null</action>
|
<action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when numberText is null</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
|
<action dev="POI-DEVELOPERS" type="fix">44985 - Properly update TextSpecInfoAtom when the parent text is changed</action>
|
||||||
|
@ -15,22 +15,20 @@
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
/*
|
|
||||||
* BiffViewer.java
|
|
||||||
*
|
|
||||||
* Created on November 13, 2001, 9:23 AM
|
|
||||||
*/
|
|
||||||
package org.apache.poi.hssf.dev;
|
package org.apache.poi.hssf.dev;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.poi.hssf.record.*;
|
import org.apache.poi.hssf.record.*;
|
||||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utillity for reading in BIFF8 records and displaying data from them.
|
* Utillity for reading in BIFF8 records and displaying data from them.
|
||||||
*
|
*
|
||||||
@ -38,38 +36,26 @@ import java.util.ArrayList;
|
|||||||
*@author Glen Stampoultzis (glens at apache.org)
|
*@author Glen Stampoultzis (glens at apache.org)
|
||||||
*@see #main
|
*@see #main
|
||||||
*/
|
*/
|
||||||
|
public final class BiffViewer {
|
||||||
public class BiffViewer {
|
private final File _inputFile;
|
||||||
String filename;
|
|
||||||
private boolean dump;
|
private boolean dump;
|
||||||
|
private final PrintStream _ps;
|
||||||
|
|
||||||
|
|
||||||
/**
|
public BiffViewer(File inFile, PrintStream ps) {
|
||||||
* Creates new BiffViewer
|
_inputFile = inFile;
|
||||||
*
|
_ps = ps;
|
||||||
*@param args
|
|
||||||
*/
|
|
||||||
|
|
||||||
public BiffViewer(String[] args) {
|
|
||||||
if (args.length > 0) {
|
|
||||||
filename = args[0];
|
|
||||||
} else {
|
|
||||||
System.out.println("BIFFVIEWER REQUIRES A FILENAME***");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method run starts up BiffViewer...
|
* Method run starts up BiffViewer...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
POIFSFileSystem fs =
|
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(_inputFile));
|
||||||
new POIFSFileSystem(new FileInputStream(filename));
|
InputStream stream = fs.createDocumentInputStream("Workbook");
|
||||||
InputStream stream =
|
createRecords(stream, dump, _ps);
|
||||||
fs.createDocumentInputStream("Workbook");
|
|
||||||
createRecords(stream, dump);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -86,451 +72,306 @@ public class BiffViewer {
|
|||||||
* InputStream
|
* InputStream
|
||||||
*@exception RecordFormatException on error processing the InputStream
|
*@exception RecordFormatException on error processing the InputStream
|
||||||
*/
|
*/
|
||||||
|
public static Record[] createRecords(InputStream in, boolean dump, PrintStream ps)
|
||||||
public static Record[] createRecords(InputStream in, boolean dump)
|
|
||||||
throws RecordFormatException {
|
throws RecordFormatException {
|
||||||
ArrayList records = new ArrayList();
|
ArrayList records = new ArrayList();
|
||||||
RecordDetails activeRecord = null;
|
RecordDetails activeRecord = null;
|
||||||
|
|
||||||
try {
|
BiffviewRecordInputStream recStream = new BiffviewRecordInputStream(in);
|
||||||
BiffviewRecordInputStream recStream = new BiffviewRecordInputStream(in);
|
while (recStream.hasNextRecord()) {
|
||||||
while (recStream.hasNextRecord()) {
|
|
||||||
recStream.nextRecord();
|
recStream.nextRecord();
|
||||||
if (recStream.getSid() != 0) {
|
if (recStream.getSid() != 0) {
|
||||||
Record record = createRecord (recStream);
|
Record record = createRecord (recStream);
|
||||||
if (record.getSid() != ContinueRecord.sid)
|
if (record.getSid() != ContinueRecord.sid)
|
||||||
{
|
{
|
||||||
records.add(record);
|
records.add(record);
|
||||||
if (activeRecord != null)
|
if (activeRecord != null)
|
||||||
activeRecord.dump();
|
activeRecord.dump(ps);
|
||||||
activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), (int)recStream.getPos(), record);
|
activeRecord = new RecordDetails(recStream.getSid(), recStream.getLength(), (int)recStream.getPos(), record);
|
||||||
}
|
}
|
||||||
if (dump) {
|
if (dump) {
|
||||||
recStream.dumpBytes();
|
recStream.dumpBytes(ps);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activeRecord.dump();
|
}
|
||||||
} catch (IOException e) {
|
if (activeRecord != null) {
|
||||||
throw new RecordFormatException("Error reading bytes", e);
|
activeRecord.dump(ps);
|
||||||
}
|
}
|
||||||
Record[] retval = new Record[records.size()];
|
Record[] retval = new Record[records.size()];
|
||||||
|
records.toArray(retval);
|
||||||
retval = (Record[]) records.toArray(retval);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void dumpNormal(Record record, int startloc, short rectype, short recsize)
|
|
||||||
{
|
|
||||||
System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
|
|
||||||
System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
|
|
||||||
System.out.println( record.toString() );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Essentially a duplicate of RecordFactory. Kept seperate as not to screw
|
* Essentially a duplicate of RecordFactory. Kept separate as not to screw
|
||||||
* up non-debug operations.
|
* up non-debug operations.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static Record createRecord( RecordInputStream in )
|
private static Record createRecord( RecordInputStream in )
|
||||||
{
|
{
|
||||||
Record retval = null;
|
|
||||||
|
|
||||||
switch ( in.getSid() )
|
switch ( in.getSid() )
|
||||||
{
|
{
|
||||||
|
|
||||||
case ChartRecord.sid:
|
case ChartRecord.sid:
|
||||||
retval = new ChartRecord( in );
|
return new ChartRecord( in );
|
||||||
break;
|
|
||||||
case ChartFormatRecord.sid:
|
case ChartFormatRecord.sid:
|
||||||
retval = new ChartFormatRecord( in );
|
return new ChartFormatRecord( in );
|
||||||
break;
|
|
||||||
case SeriesRecord.sid:
|
case SeriesRecord.sid:
|
||||||
retval = new SeriesRecord( in );
|
return new SeriesRecord( in );
|
||||||
break;
|
|
||||||
case BeginRecord.sid:
|
case BeginRecord.sid:
|
||||||
retval = new BeginRecord( in );
|
return new BeginRecord( in );
|
||||||
break;
|
|
||||||
case EndRecord.sid:
|
case EndRecord.sid:
|
||||||
retval = new EndRecord( in );
|
return new EndRecord( in );
|
||||||
break;
|
|
||||||
case BOFRecord.sid:
|
case BOFRecord.sid:
|
||||||
retval = new BOFRecord( in );
|
return new BOFRecord( in );
|
||||||
break;
|
|
||||||
case InterfaceHdrRecord.sid:
|
case InterfaceHdrRecord.sid:
|
||||||
retval = new InterfaceHdrRecord( in );
|
return new InterfaceHdrRecord( in );
|
||||||
break;
|
|
||||||
case MMSRecord.sid:
|
case MMSRecord.sid:
|
||||||
retval = new MMSRecord( in );
|
return new MMSRecord( in );
|
||||||
break;
|
|
||||||
case InterfaceEndRecord.sid:
|
case InterfaceEndRecord.sid:
|
||||||
retval = new InterfaceEndRecord( in );
|
return new InterfaceEndRecord( in );
|
||||||
break;
|
|
||||||
case WriteAccessRecord.sid:
|
case WriteAccessRecord.sid:
|
||||||
retval = new WriteAccessRecord( in );
|
return new WriteAccessRecord( in );
|
||||||
break;
|
|
||||||
case CodepageRecord.sid:
|
case CodepageRecord.sid:
|
||||||
retval = new CodepageRecord( in );
|
return new CodepageRecord( in );
|
||||||
break;
|
|
||||||
case DSFRecord.sid:
|
case DSFRecord.sid:
|
||||||
retval = new DSFRecord( in );
|
return new DSFRecord( in );
|
||||||
break;
|
|
||||||
case TabIdRecord.sid:
|
case TabIdRecord.sid:
|
||||||
retval = new TabIdRecord( in );
|
return new TabIdRecord( in );
|
||||||
break;
|
|
||||||
case FnGroupCountRecord.sid:
|
case FnGroupCountRecord.sid:
|
||||||
retval = new FnGroupCountRecord( in );
|
return new FnGroupCountRecord( in );
|
||||||
break;
|
|
||||||
case WindowProtectRecord.sid:
|
case WindowProtectRecord.sid:
|
||||||
retval = new WindowProtectRecord( in );
|
return new WindowProtectRecord( in );
|
||||||
break;
|
|
||||||
case ProtectRecord.sid:
|
case ProtectRecord.sid:
|
||||||
retval = new ProtectRecord( in );
|
return new ProtectRecord( in );
|
||||||
break;
|
|
||||||
case PasswordRecord.sid:
|
case PasswordRecord.sid:
|
||||||
retval = new PasswordRecord( in );
|
return new PasswordRecord( in );
|
||||||
break;
|
|
||||||
case ProtectionRev4Record.sid:
|
case ProtectionRev4Record.sid:
|
||||||
retval = new ProtectionRev4Record( in );
|
return new ProtectionRev4Record( in );
|
||||||
break;
|
|
||||||
case PasswordRev4Record.sid:
|
case PasswordRev4Record.sid:
|
||||||
retval = new PasswordRev4Record( in );
|
return new PasswordRev4Record( in );
|
||||||
break;
|
|
||||||
case WindowOneRecord.sid:
|
case WindowOneRecord.sid:
|
||||||
retval = new WindowOneRecord( in );
|
return new WindowOneRecord( in );
|
||||||
break;
|
|
||||||
case BackupRecord.sid:
|
case BackupRecord.sid:
|
||||||
retval = new BackupRecord( in );
|
return new BackupRecord( in );
|
||||||
break;
|
|
||||||
case HideObjRecord.sid:
|
case HideObjRecord.sid:
|
||||||
retval = new HideObjRecord( in );
|
return new HideObjRecord( in );
|
||||||
break;
|
|
||||||
case DateWindow1904Record.sid:
|
case DateWindow1904Record.sid:
|
||||||
retval = new DateWindow1904Record( in );
|
return new DateWindow1904Record( in );
|
||||||
break;
|
|
||||||
case PrecisionRecord.sid:
|
case PrecisionRecord.sid:
|
||||||
retval = new PrecisionRecord( in );
|
return new PrecisionRecord( in );
|
||||||
break;
|
|
||||||
case RefreshAllRecord.sid:
|
case RefreshAllRecord.sid:
|
||||||
retval = new RefreshAllRecord( in );
|
return new RefreshAllRecord( in );
|
||||||
break;
|
|
||||||
case BookBoolRecord.sid:
|
case BookBoolRecord.sid:
|
||||||
retval = new BookBoolRecord( in );
|
return new BookBoolRecord( in );
|
||||||
break;
|
|
||||||
case FontRecord.sid:
|
case FontRecord.sid:
|
||||||
retval = new FontRecord( in );
|
return new FontRecord( in );
|
||||||
break;
|
|
||||||
case FormatRecord.sid:
|
case FormatRecord.sid:
|
||||||
retval = new FormatRecord( in );
|
return new FormatRecord( in );
|
||||||
break;
|
|
||||||
case ExtendedFormatRecord.sid:
|
case ExtendedFormatRecord.sid:
|
||||||
retval = new ExtendedFormatRecord( in );
|
return new ExtendedFormatRecord( in );
|
||||||
break;
|
|
||||||
case StyleRecord.sid:
|
case StyleRecord.sid:
|
||||||
retval = new StyleRecord( in );
|
return new StyleRecord( in );
|
||||||
break;
|
|
||||||
case UseSelFSRecord.sid:
|
case UseSelFSRecord.sid:
|
||||||
retval = new UseSelFSRecord( in );
|
return new UseSelFSRecord( in );
|
||||||
break;
|
|
||||||
case BoundSheetRecord.sid:
|
case BoundSheetRecord.sid:
|
||||||
retval = new BoundSheetRecord( in );
|
return new BoundSheetRecord( in );
|
||||||
break;
|
|
||||||
case CountryRecord.sid:
|
case CountryRecord.sid:
|
||||||
retval = new CountryRecord( in );
|
return new CountryRecord( in );
|
||||||
break;
|
|
||||||
case SSTRecord.sid:
|
case SSTRecord.sid:
|
||||||
retval = new SSTRecord( in );
|
return new SSTRecord( in );
|
||||||
break;
|
|
||||||
case ExtSSTRecord.sid:
|
case ExtSSTRecord.sid:
|
||||||
retval = new ExtSSTRecord( in );
|
return new ExtSSTRecord( in );
|
||||||
break;
|
|
||||||
case EOFRecord.sid:
|
case EOFRecord.sid:
|
||||||
retval = new EOFRecord( in );
|
return new EOFRecord( in );
|
||||||
break;
|
|
||||||
case IndexRecord.sid:
|
case IndexRecord.sid:
|
||||||
retval = new IndexRecord( in );
|
return new IndexRecord( in );
|
||||||
break;
|
|
||||||
case CalcModeRecord.sid:
|
case CalcModeRecord.sid:
|
||||||
retval = new CalcModeRecord( in );
|
return new CalcModeRecord( in );
|
||||||
break;
|
|
||||||
case CalcCountRecord.sid:
|
case CalcCountRecord.sid:
|
||||||
retval = new CalcCountRecord( in );
|
return new CalcCountRecord( in );
|
||||||
break;
|
|
||||||
case RefModeRecord.sid:
|
case RefModeRecord.sid:
|
||||||
retval = new RefModeRecord( in );
|
return new RefModeRecord( in );
|
||||||
break;
|
|
||||||
case IterationRecord.sid:
|
case IterationRecord.sid:
|
||||||
retval = new IterationRecord( in );
|
return new IterationRecord( in );
|
||||||
break;
|
|
||||||
case DeltaRecord.sid:
|
case DeltaRecord.sid:
|
||||||
retval = new DeltaRecord( in );
|
return new DeltaRecord( in );
|
||||||
break;
|
|
||||||
case SaveRecalcRecord.sid:
|
case SaveRecalcRecord.sid:
|
||||||
retval = new SaveRecalcRecord( in );
|
return new SaveRecalcRecord( in );
|
||||||
break;
|
|
||||||
case PrintHeadersRecord.sid:
|
case PrintHeadersRecord.sid:
|
||||||
retval = new PrintHeadersRecord( in );
|
return new PrintHeadersRecord( in );
|
||||||
break;
|
|
||||||
case PrintGridlinesRecord.sid:
|
case PrintGridlinesRecord.sid:
|
||||||
retval = new PrintGridlinesRecord( in );
|
return new PrintGridlinesRecord( in );
|
||||||
break;
|
|
||||||
case GridsetRecord.sid:
|
case GridsetRecord.sid:
|
||||||
retval = new GridsetRecord( in );
|
return new GridsetRecord( in );
|
||||||
break;
|
|
||||||
case DrawingGroupRecord.sid:
|
case DrawingGroupRecord.sid:
|
||||||
retval = new DrawingGroupRecord( in );
|
return new DrawingGroupRecord( in );
|
||||||
break;
|
|
||||||
case DrawingRecordForBiffViewer.sid:
|
case DrawingRecordForBiffViewer.sid:
|
||||||
retval = new DrawingRecordForBiffViewer( in );
|
return new DrawingRecordForBiffViewer( in );
|
||||||
break;
|
|
||||||
case DrawingSelectionRecord.sid:
|
case DrawingSelectionRecord.sid:
|
||||||
retval = new DrawingSelectionRecord( in );
|
return new DrawingSelectionRecord( in );
|
||||||
break;
|
|
||||||
case GutsRecord.sid:
|
case GutsRecord.sid:
|
||||||
retval = new GutsRecord( in );
|
return new GutsRecord( in );
|
||||||
break;
|
|
||||||
case DefaultRowHeightRecord.sid:
|
case DefaultRowHeightRecord.sid:
|
||||||
retval = new DefaultRowHeightRecord( in );
|
return new DefaultRowHeightRecord( in );
|
||||||
break;
|
|
||||||
case WSBoolRecord.sid:
|
case WSBoolRecord.sid:
|
||||||
retval = new WSBoolRecord( in );
|
return new WSBoolRecord( in );
|
||||||
break;
|
|
||||||
case HeaderRecord.sid:
|
case HeaderRecord.sid:
|
||||||
retval = new HeaderRecord( in );
|
return new HeaderRecord( in );
|
||||||
break;
|
|
||||||
case FooterRecord.sid:
|
case FooterRecord.sid:
|
||||||
retval = new FooterRecord( in );
|
return new FooterRecord( in );
|
||||||
break;
|
|
||||||
case HCenterRecord.sid:
|
case HCenterRecord.sid:
|
||||||
retval = new HCenterRecord( in );
|
return new HCenterRecord( in );
|
||||||
break;
|
|
||||||
case VCenterRecord.sid:
|
case VCenterRecord.sid:
|
||||||
retval = new VCenterRecord( in );
|
return new VCenterRecord( in );
|
||||||
break;
|
|
||||||
case PrintSetupRecord.sid:
|
case PrintSetupRecord.sid:
|
||||||
retval = new PrintSetupRecord( in );
|
return new PrintSetupRecord( in );
|
||||||
break;
|
|
||||||
case DefaultColWidthRecord.sid:
|
case DefaultColWidthRecord.sid:
|
||||||
retval = new DefaultColWidthRecord( in );
|
return new DefaultColWidthRecord( in );
|
||||||
break;
|
|
||||||
case DimensionsRecord.sid:
|
case DimensionsRecord.sid:
|
||||||
retval = new DimensionsRecord( in );
|
return new DimensionsRecord( in );
|
||||||
break;
|
|
||||||
case RowRecord.sid:
|
case RowRecord.sid:
|
||||||
retval = new RowRecord( in );
|
return new RowRecord( in );
|
||||||
break;
|
|
||||||
case LabelSSTRecord.sid:
|
case LabelSSTRecord.sid:
|
||||||
retval = new LabelSSTRecord( in );
|
return new LabelSSTRecord( in );
|
||||||
break;
|
|
||||||
case RKRecord.sid:
|
case RKRecord.sid:
|
||||||
retval = new RKRecord( in );
|
return new RKRecord( in );
|
||||||
break;
|
|
||||||
case NumberRecord.sid:
|
case NumberRecord.sid:
|
||||||
retval = new NumberRecord( in );
|
return new NumberRecord( in );
|
||||||
break;
|
|
||||||
case DBCellRecord.sid:
|
case DBCellRecord.sid:
|
||||||
retval = new DBCellRecord( in );
|
return new DBCellRecord( in );
|
||||||
break;
|
|
||||||
case WindowTwoRecord.sid:
|
case WindowTwoRecord.sid:
|
||||||
retval = new WindowTwoRecord( in );
|
return new WindowTwoRecord( in );
|
||||||
break;
|
|
||||||
case SelectionRecord.sid:
|
case SelectionRecord.sid:
|
||||||
retval = new SelectionRecord( in );
|
return new SelectionRecord( in );
|
||||||
break;
|
|
||||||
case ContinueRecord.sid:
|
case ContinueRecord.sid:
|
||||||
retval = new ContinueRecord( in );
|
return new ContinueRecord( in );
|
||||||
break;
|
|
||||||
case LabelRecord.sid:
|
case LabelRecord.sid:
|
||||||
retval = new LabelRecord( in );
|
return new LabelRecord( in );
|
||||||
break;
|
|
||||||
case MulRKRecord.sid:
|
case MulRKRecord.sid:
|
||||||
retval = new MulRKRecord( in );
|
return new MulRKRecord( in );
|
||||||
break;
|
|
||||||
case MulBlankRecord.sid:
|
case MulBlankRecord.sid:
|
||||||
retval = new MulBlankRecord( in );
|
return new MulBlankRecord( in );
|
||||||
break;
|
|
||||||
case BlankRecord.sid:
|
case BlankRecord.sid:
|
||||||
retval = new BlankRecord( in );
|
return new BlankRecord( in );
|
||||||
break;
|
|
||||||
case BoolErrRecord.sid:
|
case BoolErrRecord.sid:
|
||||||
retval = new BoolErrRecord( in );
|
return new BoolErrRecord( in );
|
||||||
break;
|
|
||||||
case ColumnInfoRecord.sid:
|
case ColumnInfoRecord.sid:
|
||||||
retval = new ColumnInfoRecord( in );
|
return new ColumnInfoRecord( in );
|
||||||
break;
|
|
||||||
case MergeCellsRecord.sid:
|
case MergeCellsRecord.sid:
|
||||||
retval = new MergeCellsRecord( in );
|
return new MergeCellsRecord( in );
|
||||||
break;
|
|
||||||
case AreaRecord.sid:
|
case AreaRecord.sid:
|
||||||
retval = new AreaRecord( in );
|
return new AreaRecord( in );
|
||||||
break;
|
|
||||||
case DataFormatRecord.sid:
|
case DataFormatRecord.sid:
|
||||||
retval = new DataFormatRecord( in );
|
return new DataFormatRecord( in );
|
||||||
break;
|
|
||||||
case BarRecord.sid:
|
case BarRecord.sid:
|
||||||
retval = new BarRecord( in );
|
return new BarRecord( in );
|
||||||
break;
|
|
||||||
case DatRecord.sid:
|
case DatRecord.sid:
|
||||||
retval = new DatRecord( in );
|
return new DatRecord( in );
|
||||||
break;
|
|
||||||
case PlotGrowthRecord.sid:
|
case PlotGrowthRecord.sid:
|
||||||
retval = new PlotGrowthRecord( in );
|
return new PlotGrowthRecord( in );
|
||||||
break;
|
|
||||||
case UnitsRecord.sid:
|
case UnitsRecord.sid:
|
||||||
retval = new UnitsRecord( in );
|
return new UnitsRecord( in );
|
||||||
break;
|
|
||||||
case FrameRecord.sid:
|
case FrameRecord.sid:
|
||||||
retval = new FrameRecord( in );
|
return new FrameRecord( in );
|
||||||
break;
|
|
||||||
case ValueRangeRecord.sid:
|
case ValueRangeRecord.sid:
|
||||||
retval = new ValueRangeRecord( in );
|
return new ValueRangeRecord( in );
|
||||||
break;
|
|
||||||
case SeriesListRecord.sid:
|
case SeriesListRecord.sid:
|
||||||
retval = new SeriesListRecord( in );
|
return new SeriesListRecord( in );
|
||||||
break;
|
|
||||||
case FontBasisRecord.sid:
|
case FontBasisRecord.sid:
|
||||||
retval = new FontBasisRecord( in );
|
return new FontBasisRecord( in );
|
||||||
break;
|
|
||||||
case FontIndexRecord.sid:
|
case FontIndexRecord.sid:
|
||||||
retval = new FontIndexRecord( in );
|
return new FontIndexRecord( in );
|
||||||
break;
|
|
||||||
case LineFormatRecord.sid:
|
case LineFormatRecord.sid:
|
||||||
retval = new LineFormatRecord( in );
|
return new LineFormatRecord( in );
|
||||||
break;
|
|
||||||
case AreaFormatRecord.sid:
|
case AreaFormatRecord.sid:
|
||||||
retval = new AreaFormatRecord( in );
|
return new AreaFormatRecord( in );
|
||||||
break;
|
|
||||||
case LinkedDataRecord.sid:
|
case LinkedDataRecord.sid:
|
||||||
retval = new LinkedDataRecord( in );
|
return new LinkedDataRecord( in );
|
||||||
break;
|
|
||||||
case FormulaRecord.sid:
|
case FormulaRecord.sid:
|
||||||
retval = new FormulaRecord( in );
|
return new FormulaRecord( in );
|
||||||
break;
|
|
||||||
case SheetPropertiesRecord.sid:
|
case SheetPropertiesRecord.sid:
|
||||||
retval = new SheetPropertiesRecord( in );
|
return new SheetPropertiesRecord( in );
|
||||||
break;
|
|
||||||
case DefaultDataLabelTextPropertiesRecord.sid:
|
case DefaultDataLabelTextPropertiesRecord.sid:
|
||||||
retval = new DefaultDataLabelTextPropertiesRecord( in );
|
return new DefaultDataLabelTextPropertiesRecord( in );
|
||||||
break;
|
|
||||||
case TextRecord.sid:
|
case TextRecord.sid:
|
||||||
retval = new TextRecord( in );
|
return new TextRecord( in );
|
||||||
break;
|
|
||||||
case AxisParentRecord.sid:
|
case AxisParentRecord.sid:
|
||||||
retval = new AxisParentRecord( in );
|
return new AxisParentRecord( in );
|
||||||
break;
|
|
||||||
case AxisLineFormatRecord.sid:
|
case AxisLineFormatRecord.sid:
|
||||||
retval = new AxisLineFormatRecord( in );
|
return new AxisLineFormatRecord( in );
|
||||||
break;
|
|
||||||
case SupBookRecord.sid:
|
case SupBookRecord.sid:
|
||||||
retval = new SupBookRecord( in );
|
return new SupBookRecord( in );
|
||||||
break;
|
|
||||||
case ExternSheetRecord.sid:
|
case ExternSheetRecord.sid:
|
||||||
retval = new ExternSheetRecord( in );
|
return new ExternSheetRecord( in );
|
||||||
break;
|
|
||||||
case SCLRecord.sid:
|
case SCLRecord.sid:
|
||||||
retval = new SCLRecord( in );
|
return new SCLRecord( in );
|
||||||
break;
|
|
||||||
case SeriesToChartGroupRecord.sid:
|
case SeriesToChartGroupRecord.sid:
|
||||||
retval = new SeriesToChartGroupRecord( in );
|
return new SeriesToChartGroupRecord( in );
|
||||||
break;
|
|
||||||
case AxisUsedRecord.sid:
|
case AxisUsedRecord.sid:
|
||||||
retval = new AxisUsedRecord( in );
|
return new AxisUsedRecord( in );
|
||||||
break;
|
|
||||||
case AxisRecord.sid:
|
case AxisRecord.sid:
|
||||||
retval = new AxisRecord( in );
|
return new AxisRecord( in );
|
||||||
break;
|
|
||||||
case CategorySeriesAxisRecord.sid:
|
case CategorySeriesAxisRecord.sid:
|
||||||
retval = new CategorySeriesAxisRecord( in );
|
return new CategorySeriesAxisRecord( in );
|
||||||
break;
|
|
||||||
case AxisOptionsRecord.sid:
|
case AxisOptionsRecord.sid:
|
||||||
retval = new AxisOptionsRecord( in );
|
return new AxisOptionsRecord( in );
|
||||||
break;
|
|
||||||
case TickRecord.sid:
|
case TickRecord.sid:
|
||||||
retval = new TickRecord( in );
|
return new TickRecord( in );
|
||||||
break;
|
|
||||||
case SeriesTextRecord.sid:
|
case SeriesTextRecord.sid:
|
||||||
retval = new SeriesTextRecord( in );
|
return new SeriesTextRecord( in );
|
||||||
break;
|
|
||||||
case ObjectLinkRecord.sid:
|
case ObjectLinkRecord.sid:
|
||||||
retval = new ObjectLinkRecord( in );
|
return new ObjectLinkRecord( in );
|
||||||
break;
|
|
||||||
case PlotAreaRecord.sid:
|
case PlotAreaRecord.sid:
|
||||||
retval = new PlotAreaRecord( in );
|
return new PlotAreaRecord( in );
|
||||||
break;
|
|
||||||
case SeriesIndexRecord.sid:
|
case SeriesIndexRecord.sid:
|
||||||
retval = new SeriesIndexRecord( in );
|
return new SeriesIndexRecord( in );
|
||||||
break;
|
|
||||||
case LegendRecord.sid:
|
case LegendRecord.sid:
|
||||||
retval = new LegendRecord( in );
|
return new LegendRecord( in );
|
||||||
break;
|
|
||||||
case LeftMarginRecord.sid:
|
case LeftMarginRecord.sid:
|
||||||
retval = new LeftMarginRecord( in );
|
return new LeftMarginRecord( in );
|
||||||
break;
|
|
||||||
case RightMarginRecord.sid:
|
case RightMarginRecord.sid:
|
||||||
retval = new RightMarginRecord( in );
|
return new RightMarginRecord( in );
|
||||||
break;
|
|
||||||
case TopMarginRecord.sid:
|
case TopMarginRecord.sid:
|
||||||
retval = new TopMarginRecord( in );
|
return new TopMarginRecord( in );
|
||||||
break;
|
|
||||||
case BottomMarginRecord.sid:
|
case BottomMarginRecord.sid:
|
||||||
retval = new BottomMarginRecord( in );
|
return new BottomMarginRecord( in );
|
||||||
break;
|
|
||||||
case PaletteRecord.sid:
|
case PaletteRecord.sid:
|
||||||
retval = new PaletteRecord( in );
|
return new PaletteRecord( in );
|
||||||
break;
|
|
||||||
case StringRecord.sid:
|
case StringRecord.sid:
|
||||||
retval = new StringRecord( in );
|
return new StringRecord( in );
|
||||||
break;
|
|
||||||
case NameRecord.sid:
|
case NameRecord.sid:
|
||||||
retval = new NameRecord( in );
|
return new NameRecord( in );
|
||||||
break;
|
|
||||||
case PaneRecord.sid:
|
case PaneRecord.sid:
|
||||||
retval = new PaneRecord( in );
|
return new PaneRecord( in );
|
||||||
break;
|
|
||||||
case SharedFormulaRecord.sid:
|
case SharedFormulaRecord.sid:
|
||||||
retval = new SharedFormulaRecord( in);
|
return new SharedFormulaRecord( in);
|
||||||
break;
|
|
||||||
case ObjRecord.sid:
|
case ObjRecord.sid:
|
||||||
retval = new ObjRecord( in);
|
return new ObjRecord( in);
|
||||||
break;
|
|
||||||
case TextObjectRecord.sid:
|
case TextObjectRecord.sid:
|
||||||
retval = new TextObjectRecord( in);
|
return new TextObjectRecord( in);
|
||||||
break;
|
|
||||||
case HorizontalPageBreakRecord.sid:
|
case HorizontalPageBreakRecord.sid:
|
||||||
retval = new HorizontalPageBreakRecord( in);
|
return new HorizontalPageBreakRecord( in);
|
||||||
break;
|
|
||||||
case VerticalPageBreakRecord.sid:
|
case VerticalPageBreakRecord.sid:
|
||||||
retval = new VerticalPageBreakRecord( in);
|
return new VerticalPageBreakRecord( in);
|
||||||
break;
|
|
||||||
case WriteProtectRecord.sid:
|
case WriteProtectRecord.sid:
|
||||||
retval = new WriteProtectRecord( in);
|
return new WriteProtectRecord( in);
|
||||||
break;
|
|
||||||
case FilePassRecord.sid:
|
case FilePassRecord.sid:
|
||||||
retval = new FilePassRecord(in);
|
return new FilePassRecord(in);
|
||||||
break;
|
|
||||||
case NoteRecord.sid:
|
case NoteRecord.sid:
|
||||||
retval = new NoteRecord( in );
|
return new NoteRecord( in );
|
||||||
break;
|
|
||||||
case FileSharingRecord.sid:
|
case FileSharingRecord.sid:
|
||||||
retval = new FileSharingRecord( in );
|
return new FileSharingRecord( in );
|
||||||
break;
|
|
||||||
case HyperlinkRecord.sid:
|
case HyperlinkRecord.sid:
|
||||||
retval = new HyperlinkRecord( in );
|
return new HyperlinkRecord( in );
|
||||||
break;
|
|
||||||
default:
|
|
||||||
retval = new UnknownRecord( in );
|
|
||||||
}
|
}
|
||||||
return retval;
|
return new UnknownRecord( in );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method setDump - hex dump out data or not.
|
* Method setDump - hex dump out data or not.
|
||||||
*
|
|
||||||
*@param dump
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setDump(boolean dump) {
|
public void setDump(boolean dump) {
|
||||||
this.dump = dump;
|
this.dump = dump;
|
||||||
}
|
}
|
||||||
@ -552,33 +393,44 @@ public class BiffViewer {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
System.setProperty("poi.deserialize.escher", "true");
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
System.out.println( "Biff viewer needs a filename" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.setProperty("poi.deserialize.escher", "true");
|
String inFileName = args[0];
|
||||||
|
File inputFile = new File(inFileName);
|
||||||
if (args.length == 0)
|
if(!inputFile.exists()) {
|
||||||
{
|
throw new RuntimeException("specified inputFile '" + inFileName + "' does not exist");
|
||||||
System.out.println( "Biff viewer needs a filename" );
|
|
||||||
}
|
}
|
||||||
else
|
PrintStream ps;
|
||||||
{
|
if (false) { // set to true to output to file
|
||||||
BiffViewer viewer = new BiffViewer(args);
|
OutputStream os = new FileOutputStream(inFileName + ".out");
|
||||||
if ((args.length > 1) && args[1].equals("on")) {
|
ps = new PrintStream(os);
|
||||||
viewer.setDump(true);
|
} else {
|
||||||
}
|
ps = System.out;
|
||||||
if ((args.length > 1) && args[1].equals("bfd")) {
|
|
||||||
POIFSFileSystem fs =
|
|
||||||
new POIFSFileSystem(new FileInputStream(args[0]));
|
|
||||||
InputStream stream =
|
|
||||||
fs.createDocumentInputStream("Workbook");
|
|
||||||
int size = stream.available();
|
|
||||||
byte[] data = new byte[size];
|
|
||||||
|
|
||||||
stream.read(data);
|
|
||||||
HexDump.dump(data, 0, System.out, 0);
|
|
||||||
} else {
|
|
||||||
viewer.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BiffViewer viewer = new BiffViewer(inputFile, ps);
|
||||||
|
|
||||||
|
if (args.length > 1 && args[1].equals("on")) {
|
||||||
|
viewer.setDump(true);
|
||||||
|
}
|
||||||
|
if (args.length > 1 && args[1].equals("bfd")) {
|
||||||
|
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(inputFile));
|
||||||
|
InputStream stream = fs.createDocumentInputStream("Workbook");
|
||||||
|
int size = stream.available();
|
||||||
|
byte[] data = new byte[size];
|
||||||
|
|
||||||
|
stream.read(data);
|
||||||
|
HexDump.dump(data, 0, System.out, 0);
|
||||||
|
} else {
|
||||||
|
viewer.run();
|
||||||
|
}
|
||||||
|
ps.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -587,7 +439,7 @@ public class BiffViewer {
|
|||||||
/**
|
/**
|
||||||
* This record supports dumping of completed continue records.
|
* This record supports dumping of completed continue records.
|
||||||
*/
|
*/
|
||||||
static class RecordDetails
|
private static final class RecordDetails
|
||||||
{
|
{
|
||||||
short rectype, recsize;
|
short rectype, recsize;
|
||||||
int startloc;
|
int startloc;
|
||||||
@ -616,18 +468,19 @@ public class BiffViewer {
|
|||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump() throws IOException
|
public void dump(PrintStream ps) {
|
||||||
{
|
ps.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
|
||||||
dumpNormal(record, startloc, rectype, recsize);
|
ps.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
|
||||||
|
ps.println( record.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BiffviewRecordInputStream extends RecordInputStream {
|
private static final class BiffviewRecordInputStream extends RecordInputStream {
|
||||||
public BiffviewRecordInputStream(InputStream in) {
|
public BiffviewRecordInputStream(InputStream in) {
|
||||||
super(in);
|
super(in);
|
||||||
}
|
}
|
||||||
public void dumpBytes() {
|
public void dumpBytes(PrintStream ps) {
|
||||||
HexDump.dump(this.data, 0, this.currentLength);
|
ps.println(HexDump.dump(this.data, 0, this.currentLength));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,4 +140,13 @@ public class HSSFName implements Name {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if this name points to a cell that no longer exists
|
||||||
|
*
|
||||||
|
* @return true if the name refers to a deleted cell, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isDeleted(){
|
||||||
|
String ref = getReference();
|
||||||
|
return "#REF!".endsWith(ref);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
|||||||
|
|
||||||
protected HSSFWorkbook( Workbook book )
|
protected HSSFWorkbook( Workbook book )
|
||||||
{
|
{
|
||||||
super(null, null);
|
super(null, null);
|
||||||
workbook = book;
|
workbook = book;
|
||||||
sheets = new ArrayList( INITIAL_CAPACITY );
|
sheets = new ArrayList( INITIAL_CAPACITY );
|
||||||
names = new ArrayList( INITIAL_CAPACITY );
|
names = new ArrayList( INITIAL_CAPACITY );
|
||||||
@ -775,14 +775,54 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* removes sheet at the given index
|
* Removes sheet at the given index.<p/>
|
||||||
|
*
|
||||||
|
* Care must be taken if the removed sheet is the currently active or only selected sheet in
|
||||||
|
* the workbook. There are a few situations when Excel must have a selection and/or active
|
||||||
|
* sheet. (For example when printing - see Bug 40414).<br/>
|
||||||
|
*
|
||||||
|
* This method makes sure that if the removed sheet was active, another sheet will become
|
||||||
|
* active in its place. Furthermore, if the removed sheet was the only selected sheet, another
|
||||||
|
* sheet will become selected. The newly active/selected sheet will have the same index, or
|
||||||
|
* one less if the removed sheet was the last in the workbook.
|
||||||
|
*
|
||||||
* @param index of the sheet (0-based)
|
* @param index of the sheet (0-based)
|
||||||
*/
|
*/
|
||||||
|
public void removeSheetAt(int index) {
|
||||||
|
validateSheetIndex(index);
|
||||||
|
boolean wasActive = getSheetAt(index).isActive();
|
||||||
|
boolean wasSelected = getSheetAt(index).isSelected();
|
||||||
|
|
||||||
public void removeSheetAt(int index)
|
|
||||||
{
|
|
||||||
sheets.remove(index);
|
sheets.remove(index);
|
||||||
workbook.removeSheet(index);
|
workbook.removeSheet(index);
|
||||||
|
|
||||||
|
// set the remaining active/selected sheet
|
||||||
|
int nSheets = sheets.size();
|
||||||
|
if (nSheets < 1) {
|
||||||
|
// nothing more to do if there are no sheets left
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// the index of the closest remaining sheet to the one just deleted
|
||||||
|
int newSheetIndex = index;
|
||||||
|
if (newSheetIndex >= nSheets) {
|
||||||
|
newSheetIndex = nSheets-1;
|
||||||
|
}
|
||||||
|
if (wasActive) {
|
||||||
|
setActiveSheet(newSheetIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wasSelected) {
|
||||||
|
boolean someOtherSheetIsStillSelected = false;
|
||||||
|
for (int i =0; i < nSheets; i++) {
|
||||||
|
if (getSheetAt(i).isSelected()) {
|
||||||
|
someOtherSheetIsStillSelected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!someOtherSheetIsStillSelected) {
|
||||||
|
setSelectedTab(newSheetIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
BIN
src/testcases/org/apache/poi/hssf/data/24207.xls
Executable file
BIN
src/testcases/org/apache/poi/hssf/data/24207.xls
Executable file
Binary file not shown.
BIN
src/testcases/org/apache/poi/hssf/data/36947.xls
Executable file
BIN
src/testcases/org/apache/poi/hssf/data/36947.xls
Executable file
Binary file not shown.
BIN
src/testcases/org/apache/poi/hssf/data/39634.xls
Executable file
BIN
src/testcases/org/apache/poi/hssf/data/39634.xls
Executable file
Binary file not shown.
@ -911,4 +911,45 @@ public final class TestBugs extends TestCase {
|
|||||||
writeOutAndReadBack(wb);
|
writeOutAndReadBack(wb);
|
||||||
assertTrue("no errors writing sample xls", true);
|
assertTrue("no errors writing sample xls", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bug 21334: "File error: data may have been lost" with a file
|
||||||
|
* that contains macros and this formula:
|
||||||
|
* {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))}
|
||||||
|
*/
|
||||||
|
public void test21334() {
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFSheet sh = wb.createSheet();
|
||||||
|
HSSFCell cell = sh.createRow(0).createCell((short)0);
|
||||||
|
String formula = "SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),\"\"))>0,1))";
|
||||||
|
cell.setCellFormula(formula);
|
||||||
|
|
||||||
|
HSSFWorkbook wb_sv = writeOutAndReadBack(wb);
|
||||||
|
HSSFCell cell_sv = wb_sv.getSheetAt(0).getRow(0).getCell((short)0);
|
||||||
|
assertEquals(formula, cell_sv.getCellFormula());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test36947() throws Exception {
|
||||||
|
HSSFWorkbook wb = openSample("36947.xls");
|
||||||
|
assertTrue("no errors reading sample xls", true);
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
assertTrue("no errors writing sample xls", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69
|
||||||
|
*/
|
||||||
|
public void test42448(){
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFCell cell = wb.createSheet().createRow(0).createCell((short)0);
|
||||||
|
cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69");
|
||||||
|
assertTrue("no errors parsing formula", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void test39634() throws Exception {
|
||||||
|
HSSFWorkbook wb = openSample("39634.xls");
|
||||||
|
assertTrue("no errors reading sample xls", true);
|
||||||
|
writeOutAndReadBack(wb);
|
||||||
|
assertTrue("no errors writing sample xls", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,11 +232,11 @@ public final class TestHSSFWorkbook extends TestCase {
|
|||||||
// Demonstrate bug 44525:
|
// Demonstrate bug 44525:
|
||||||
// Well... not quite, since isActive + isSelected were also added in the same bug fix
|
// Well... not quite, since isActive + isSelected were also added in the same bug fix
|
||||||
if (sheet1.isSelected()) {
|
if (sheet1.isSelected()) {
|
||||||
throw new AssertionFailedError("Identified bug 44525 a");
|
throw new AssertionFailedError("Identified bug 44523 a");
|
||||||
}
|
}
|
||||||
wb.setActiveSheet(1);
|
wb.setActiveSheet(1);
|
||||||
if (sheet1.isActive()) {
|
if (sheet1.isActive()) {
|
||||||
throw new AssertionFailedError("Identified bug 44525 b");
|
throw new AssertionFailedError("Identified bug 44523 b");
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmActiveSelected(sheet1, false);
|
confirmActiveSelected(sheet1, false);
|
||||||
@ -299,8 +299,81 @@ public final class TestHSSFWorkbook extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testActiveSheetAfterDelete_bug40414() {
|
||||||
|
HSSFWorkbook wb=new HSSFWorkbook();
|
||||||
|
HSSFSheet sheet0 = wb.createSheet("Sheet0");
|
||||||
|
HSSFSheet sheet1 = wb.createSheet("Sheet1");
|
||||||
|
HSSFSheet sheet2 = wb.createSheet("Sheet2");
|
||||||
|
HSSFSheet sheet3 = wb.createSheet("Sheet3");
|
||||||
|
HSSFSheet sheet4 = wb.createSheet("Sheet4");
|
||||||
|
|
||||||
|
// confirm default activation/selection
|
||||||
|
confirmActiveSelected(sheet0, true);
|
||||||
|
confirmActiveSelected(sheet1, false);
|
||||||
|
confirmActiveSelected(sheet2, false);
|
||||||
|
confirmActiveSelected(sheet3, false);
|
||||||
|
confirmActiveSelected(sheet4, false);
|
||||||
|
|
||||||
|
wb.setActiveSheet(3);
|
||||||
|
wb.setSelectedTab(3);
|
||||||
|
|
||||||
|
confirmActiveSelected(sheet0, false);
|
||||||
|
confirmActiveSelected(sheet1, false);
|
||||||
|
confirmActiveSelected(sheet2, false);
|
||||||
|
confirmActiveSelected(sheet3, true);
|
||||||
|
confirmActiveSelected(sheet4, false);
|
||||||
|
|
||||||
|
wb.removeSheetAt(3);
|
||||||
|
// after removing the only active/selected sheet, another should be active/selected in its place
|
||||||
|
if (!sheet4.isSelected()) {
|
||||||
|
throw new AssertionFailedError("identified bug 40414 a");
|
||||||
|
}
|
||||||
|
if (!sheet4.isActive()) {
|
||||||
|
throw new AssertionFailedError("identified bug 40414 b");
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmActiveSelected(sheet0, false);
|
||||||
|
confirmActiveSelected(sheet1, false);
|
||||||
|
confirmActiveSelected(sheet2, false);
|
||||||
|
confirmActiveSelected(sheet4, true);
|
||||||
|
|
||||||
|
sheet3 = sheet4; // re-align local vars in this test case
|
||||||
|
|
||||||
|
// Some more cases of removing sheets
|
||||||
|
|
||||||
|
// Starting with a multiple selection, and different active sheet
|
||||||
|
wb.setSelectedTabs(new int[] { 1, 3, });
|
||||||
|
wb.setActiveSheet(2);
|
||||||
|
confirmActiveSelected(sheet0, false, false);
|
||||||
|
confirmActiveSelected(sheet1, false, true);
|
||||||
|
confirmActiveSelected(sheet2, true, false);
|
||||||
|
confirmActiveSelected(sheet3, false, true);
|
||||||
|
|
||||||
|
// removing a sheet that is not active, and not the only selected sheet
|
||||||
|
wb.removeSheetAt(3);
|
||||||
|
confirmActiveSelected(sheet0, false, false);
|
||||||
|
confirmActiveSelected(sheet1, false, true);
|
||||||
|
confirmActiveSelected(sheet2, true, false);
|
||||||
|
|
||||||
|
// removing the only selected sheet
|
||||||
|
wb.removeSheetAt(1);
|
||||||
|
confirmActiveSelected(sheet0, false, false);
|
||||||
|
confirmActiveSelected(sheet2, true, true);
|
||||||
|
|
||||||
|
// The last remaining sheet should always be active+selected
|
||||||
|
wb.removeSheetAt(1);
|
||||||
|
confirmActiveSelected(sheet0, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
private static void confirmActiveSelected(HSSFSheet sheet, boolean expected) {
|
private static void confirmActiveSelected(HSSFSheet sheet, boolean expected) {
|
||||||
assertEquals(expected, sheet.isActive());
|
confirmActiveSelected(sheet, expected, expected);
|
||||||
assertEquals(expected, sheet.isSelected());
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void confirmActiveSelected(HSSFSheet sheet,
|
||||||
|
boolean expectedActive, boolean expectedSelected) {
|
||||||
|
assertEquals("active", expectedActive, sheet.isActive());
|
||||||
|
assertEquals("selected", expectedSelected, sheet.isSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,4 +533,28 @@ public final class TestNamedRange extends TestCase {
|
|||||||
String contents = c.getStringCellValue();
|
String contents = c.getStringCellValue();
|
||||||
assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
|
assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeletedReference() throws Exception {
|
||||||
|
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("24207.xls");
|
||||||
|
assertEquals(2, wb.getNumberOfNames());
|
||||||
|
|
||||||
|
HSSFName name1 = wb.getNameAt(0);
|
||||||
|
assertEquals("a", name1.getNameName());
|
||||||
|
assertEquals("Sheet1!$A$1", name1.getReference());
|
||||||
|
AreaReference ref1 = new AreaReference(name1.getReference());
|
||||||
|
assertTrue("Successfully constructed first reference", true);
|
||||||
|
|
||||||
|
HSSFName name2 = wb.getNameAt(1);
|
||||||
|
assertEquals("b", name2.getNameName());
|
||||||
|
assertEquals("#REF!", name2.getReference());
|
||||||
|
assertTrue(name2.isDeleted());
|
||||||
|
try {
|
||||||
|
AreaReference ref2 = new AreaReference(name2.getReference());
|
||||||
|
fail("attempt to supply an invalid reference to AreaReference constructor results in exception");
|
||||||
|
} catch (Exception e){
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user