Lines 167-180
Link Here
|
167 |
setPropertiesFromWorkbook(workbook); |
167 |
setPropertiesFromWorkbook(workbook); |
168 |
int recOffset = workbook.getNumRecords(); |
168 |
int recOffset = workbook.getNumRecords(); |
169 |
int sheetNum = 0; |
169 |
int sheetNum = 0; |
170 |
|
170 |
convertLabelRecords(records); |
171 |
while (recOffset < records.size()) |
171 |
while (recOffset < records.size()) |
172 |
{ |
172 |
{ |
173 |
Sheet sheet = Sheet.createSheet(records, sheetNum++, recOffset ); |
173 |
Sheet sheet = Sheet.createSheet(records, sheetNum++, recOffset ); |
174 |
|
174 |
|
175 |
recOffset = sheet.getEofLoc()+1; |
175 |
recOffset = sheet.getEofLoc()+1; |
176 |
sheet.convertLabelRecords( |
|
|
177 |
workbook); // convert all LabelRecord records to LabelSSTRecord |
178 |
HSSFSheet hsheet = new HSSFSheet(workbook, sheet); |
176 |
HSSFSheet hsheet = new HSSFSheet(workbook, sheet); |
179 |
|
177 |
|
180 |
sheets.add(hsheet); |
178 |
sheets.add(hsheet); |
Lines 1068-1073
Link Here
|
1068 |
workbook.getRecords().add(loc, r); |
1066 |
workbook.getRecords().add(loc, r); |
1069 |
} |
1067 |
} |
1070 |
|
1068 |
|
|
|
1069 |
/** |
1070 |
* This is basically a kludge to deal with the now obsolete Label records. If |
1071 |
* you have to read in a sheet that contains Label records, be aware that the rest |
1072 |
* of the API doesn't deal with them, the low level structure only provides read-only |
1073 |
* semi-immutable structures (the sets are there for interface conformance with NO |
1074 |
* impelmentation). In short, you need to call this function passing it a reference |
1075 |
* to the Workbook object. All labels will be converted to LabelSST records and their |
1076 |
* contained strings will be written to the Shared String tabel (SSTRecord) within |
1077 |
* the Workbook. |
1078 |
* |
1079 |
* @param wb sheet's matching low level Workbook structure containing the SSTRecord. |
1080 |
* @see org.apache.poi.hssf.record.LabelRecord |
1081 |
* @see org.apache.poi.hssf.record.LabelSSTRecord |
1082 |
* @see org.apache.poi.hssf.record.SSTRecord |
1083 |
*/ |
1084 |
public void convertLabelRecords(List records) |
1085 |
{ |
1086 |
if (log.check(POILogger.DEBUG)) |
1087 |
log.log(POILogger.DEBUG, "convertLabelRecords called"); |
1088 |
for (int k = 0; k < records.size(); k++) |
1089 |
{ |
1090 |
Record rec = (Record) records.get(k); |
1091 |
if (rec.getSid() == LabelRecord.sid) |
1092 |
{ |
1093 |
LabelRecord oldrec = (LabelRecord) rec; |
1094 |
records.remove(k); |
1095 |
LabelSSTRecord newrec = new LabelSSTRecord(); |
1096 |
int stringid = addSSTString(oldrec.getValue()); |
1097 |
newrec.setRow(oldrec.getRow()); |
1098 |
newrec.setColumn(oldrec.getColumn()); |
1099 |
newrec.setXFIndex(oldrec.getXFIndex()); |
1100 |
newrec.setSSTIndex(stringid); |
1101 |
records.add(k, newrec); |
1102 |
} |
1103 |
} |
1104 |
if (log.check(POILogger.DEBUG)) |
1105 |
log.log(POILogger.DEBUG, "convertLabelRecords exit"); |
1106 |
} |
1071 |
|
1107 |
|
1072 |
|
1108 |
|
1073 |
} |
1109 |
} |