LINQ to XML을 사용하여 Excel XML 파일을 만듭니다. 셀 안에 개조 문자를 포함하고 싶습니다. Excel에서는
리터럴을 사용하여 새 줄을 나타냅니다. 내가 XText 사용하여이를 추가하려고하면 :Excel의 XML 줄 바꾸기
XText newlineElement = new XText("Foo Bar");
를 내가 얻을 : 엑셀에 표시
Foo
Bar
:
Foo Bar
는 방식이 있나요 do
없이 XML 파일에

을 작성하십시오.
String.Replace("
", " ")
결과 파일 텍스트 위에?
EDIT 다음은 Excel 문서의 행을 만드는 방법을 보여주는 코드입니다. 좀 지저분하기 때문에 나는 그것을 피하고 있었다. :) 더 많은 코드가 도움이되는지 아니면 더 많은 혼란이 추가되는지 알려주십시오.
이 예제에서 위에 설명 된 newlineElement
은 코드 샘플에서 XText로만 표현됩니다.
const string CELL = "{urn:schemas-microsoft-com:office:spreadsheet}Cell";
const string DATA = "{urn:schemas-microsoft-com:office:spreadsheet}Data";
const string STYLE = "{urn:schemas-microsoft-com:office:spreadsheet}StyleID";
const string TYPE= "{urn:schemas-microsoft-com:office:spreadsheet}Type";
const string HEIGHT = "{urn:schemas-microsoft-com:office:spreadsheet}Height";
const string ROW = "{urn:schemas-microsoft-com:office:spreadsheet}Row";
...
XElement rowElement = new XElement(Row,
new XElement(CELL,
new XAttribute(STYLE, "s0")),
new XElement(CELL,
new XElement(DATA,
new XText(description.Replace("\n", " ")),
new XAttribute(TYPE, "String")),
new XAttribute(STYLE, "sWrap")),
new XElement(CELL,
new XAttribute(STYLE, "s0")),
new XAttribute(HEIGHT, height));
이것은 생산 : 도움을
<ss:Row ss:Height="45">
<ss:Cell ss:StyleID="s0" />
<ss:Cell ss:StyleID="sWrap">
<ss:Data ss:Type="String">Foo&#10;Bar</ss:Data>
</ss:Cell>
<ss:Cell ss:StyleID="s0" />
</ss:Row>
감사합니다 지금까지!
믿거 나 말거나 가능하지 않습니다. – SLaks
Excel 파일에 어떻게 들어 오는지 예제 코드를 게시 할 수 있습니까? – CoderDennis
기본적으로 newlineElement 객체를 만든 후에 어떻게 사용하고 있는지 보여주는 코드를 보면 좋을 것입니다. – CoderDennis