开发者

HTML pasted text into Excel keeping formatting

I'm using Flex to generate text that will be copied to the clipboard so a user can paste a grid into Excel. For instance it might generate the following text which can be copied into Excel:

<html>
    <body>
        <table>
            <thead>
                <tr>
                    <th>COL1</th>
                    <th>COL2</th>
                    <th>COL3</th>
               开发者_JS百科 </tr>
            </thead>
            <tbody>
                <tr>
                    <td>row1col1</td>
                    <td>0001234</td>
                    <td>row1col3</td>
                </tr>
                <tr>
                    <td>row2col1</td>
                    <td>0003456</td>
                    <td>row2col3</td>
                </tr>
                <tr>
                    <td>row3col1</td>
                    <td>0007890</td>
                    <td>row3col3</td>
                </tr>
            </tbody>
        </table>
    </body>
</html>

I have some columns that contain numbers that should be considered text, for instance they have leading zeros that shouldn't be removed. How do I set the formatting for these columns so the leading zeros don't get removed in Excel?


I found it. I guess you can just set the mso-number-format style: <td style="mso-number-format:\@">0001234</td>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜