PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.2k forks source link

Excel2007 Text box support #1352

Open tsomeq opened 6 years ago

tsomeq commented 6 years ago

I have a xlsx file, that contains text boxes . I want to export all text contents from xls file, but it seems to be ignored.

The xlsx file is identified as an Excel2007 formatted file. It contains xml source as "xl/drawings/drawing1.xml" in extracted xlsx like below :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xdr:wsDr
   xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
   xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
 <!--
 ... snip ...
 -->
 <xdr:oneCellAnchor>
    <xdr:from>
        <xdr:col>7</xdr:col><xdr:colOff>47160</xdr:colOff>
        <xdr:row>1</xdr:row><xdr:rowOff>13939</xdr:rowOff>
    </xdr:from>
    <xdr:ext cx="171450" cy="378677"/>
    <xdr:sp macro="" textlink="">
        <xdr:txBody>
            <a:bodyPr wrap="square" lIns="18288" tIns="18288" rIns="0" bIns="0" anchor="t" upright="1">
                <a:noAutofit/>
            </a:bodyPr>
            <a:lstStyle/>
            <a:p>
                <a:pPr algn="l" rtl="0">
                  <a:lnSpc><a:spcPts val="1100"/></a:lnSpc>
                  <a:defRPr sz="1000"/>
                </a:pPr>
                <a:r>
                <a:rPr lang="ja-JP" altLang="en-US" sz="900" b="0" i="0" u="none" strike="noStrike" baseline="0">
                <a:solidFill><a:srgbClr val="000000"/></a:solidFill>
                <a:latin typeface="MS 明朝" panose="02020609040205080304" pitchFamily="17" charset="-128"/>
                <a:ea typeface="MS 明朝" panose="02020609040205080304" pitchFamily="17" charset="-128"/>
                </a:rPr>
                <a:t>届書</a:t>
                </a:r>
            </a:p>
        </xdr:txBody>
 <!--  ... -->

In source code Classes/PHPExcel/Reader/Excel2007.php, The reader can parse "xdr:graphicFrame" and "xdr:pic/xdr:blipFill" , but cannot parse "xdr:sp/xdr:txtBody".

How do you think supporting text-box object ?

If it is difficult , alternatively calling some callback function after detection of unknown node could be fine. e.g. :

$reader->setHandlerOnDetectedUnknownTag(function($worksheet, $node){ ... });

The sample xlsx file can be download from here: Direct download On Web site This file contains some text boxes to mark.

Thanks for reading.