ASF Bugzilla – Attachment 24529 Details for
Bug 47757
Example code XLSX2CSV using event API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch that incorporates Eric Smith's fix to the problem he discovered.
patch.txt (text/plain), 4.39 KB, created by
Chris Lott
on 2009-11-13 05:36:08 UTC
(
hide
)
Description:
Patch that incorporates Eric Smith's fix to the problem he discovered.
Filename:
MIME Type:
Creator:
Chris Lott
Created:
2009-11-13 05:36:08 UTC
Size:
4.39 KB
patch
obsolete
>*** XLSX2CSV.java Fri Nov 13 08:04:14 2009 >--- patched/XLSX2CSV.java Fri Nov 13 08:31:01 2009 >*************** >*** 15,21 **** > limitations under the License. > ==================================================================== */ > >! package org.apache.poi.xssf.eventusermodel; > > import java.io.File; > import java.io.IOException; >--- 15,21 ---- > limitations under the License. > ==================================================================== */ > >! package org.apache.poi.xssf.eventusermodel.patched; > > import java.io.File; > import java.io.IOException; >*************** import org.apache.poi.openxml4j.opc.Pack >*** 34,39 **** >--- 34,40 ---- > import org.apache.poi.openxml4j.opc.PackageRelationship; > import org.apache.poi.ss.usermodel.BuiltinFormats; > import org.apache.poi.ss.usermodel.DataFormatter; >+ import org.apache.poi.xssf.eventusermodel.XSSFReader; > import org.apache.poi.xssf.model.StylesTable; > import org.apache.poi.xssf.usermodel.XSSFCellStyle; > import org.apache.poi.xssf.usermodel.XSSFRichTextString; >*************** import org.xml.sax.helpers.DefaultHandle >*** 60,66 **** > * (read-only) class is used for the shared string table > * because the standard POI SharedStringsTable grows very > * quickly with the number of unique strings. >! * > * @author Chris Lott > */ > public class XLSX2CSV { >--- 61,72 ---- > * (read-only) class is used for the shared string table > * because the standard POI SharedStringsTable grows very > * quickly with the number of unique strings. >! * <p/> >! * Thanks to Eric Smith for a patch that fixes a problem >! * triggered by cells with multiple "t" elements, which is >! * how Excel represents different formats (e.g., one word >! * plain and one word bold). >! * > * @author Chris Lott > */ > public class XLSX2CSV { >*************** public class XLSX2CSV { >*** 78,83 **** >--- 84,126 ---- > NUMBER, > } > >+ /** >+ * Each cell is enclosed in "si". Each cell can have multiple "t" elements. >+ * Example input >+ * >+ * <pre> >+ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> >+ <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="2" uniqueCount="2"> >+ <si> >+ <r> >+ <rPr> >+ <b /> >+ <sz val="11" /> >+ <color theme="1" /> >+ <rFont val="Calibri" /> >+ <family val="2" /> >+ <scheme val="minor" /> >+ </rPr> >+ <t>This:</t> >+ </r> >+ <r> >+ <rPr> >+ <sz val="11" /> >+ <color theme="1" /> >+ <rFont val="Calibri" /> >+ <family val="2" /> >+ <scheme val="minor" /> >+ </rPr> >+ <t xml:space="preserve">Causes Problems</t> >+ </r> >+ </si> >+ <si> >+ <t>This does not</t> >+ </si> >+ </sst> >+ * </pre> >+ * >+ */ > static class ReadonlySharedStringsTable extends DefaultHandler { > > /** >*************** public class XLSX2CSV { >*** 192,199 **** > this.strings = new String[this.uniqueCount]; > index = 0; > characters = new StringBuffer(); >! } else if ("t".equals(name)) { > characters.setLength(0); > tIsOpen = true; > } > } >--- 235,243 ---- > this.strings = new String[this.uniqueCount]; > index = 0; > characters = new StringBuffer(); >! } else if ("si".equals(name)) { > characters.setLength(0); >+ } else if ("t".equals(name)) { > tIsOpen = true; > } > } >*************** public class XLSX2CSV { >*** 204,212 **** > */ > public void endElement(String uri, String localName, String name) > throws SAXException { >! if ("t".equals(name)) { >! strings[index] = characters.toString(); > ++index; > } > } > >--- 248,258 ---- > */ > public void endElement(String uri, String localName, String name) > throws SAXException { >! if ("si".equals(name)) { >! strings[index] = characters.toString(); > ++index; >+ } else if ("t".equals(name)) { >+ tIsOpen = false; > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47757
:
24183
|
24528
| 24529