Style for wrapped text with spreadsheetml

瘦欲@ 提交于 2019-12-10 14:26:27

问题


I generate my spreadsheet with xslt and want a cell with wrapped text (or better: a text with a line break in it).

So my xslt generates the following XML for the sheetdata:

<sheetData>
  <row r="1">
    <c r="A1" t="inlineStr">
      <is>
        <t>
          a simple string
          line break jeeeehaaa
        </t>
      </is>
    </c>
  </row>
</sheetData>

After I'm finished building my Workbook, I open it in Excel; and there's no line break, just a simple one-line string in A1.

has anyone a solution to this? Doesn't have to be in xml or xslt (but would be nice). I could also do some things in c#


回答1:


In excel, all style related information is stored in style.xml file. So, the wrapping information should be stored in style.xml and the style Id should be referred in <c r="A1" t="inlineStr"> as one more attribute 's' (which means style). Let me show what do I mean by this..

I do have an excel with some text and the cell is wrapped indeed.

If I see its sheet.xml data it would have s="1" attribute-value item in <c> tag.

So, if I open style.xml and see the cell style info I'll get <cellXfs> tag and a <xf> child tag where I get a <alignment> tag with wrapText attribute with value as "1" ("true" indeed).

I'm unable to post images since I'm new to SO. Hope this helps :)



来源:https://stackoverflow.com/questions/10142095/style-for-wrapped-text-with-spreadsheetml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!