스타일은 Excel 문서의 CellFormats
섹션에서 처리됩니다. 셀이 형식이 때 XML보고하고 s
속성이 정수로 설정되어있는 것을 볼 때 알 수 있습니다 :
<x:c r="A1" s="1" t="s" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<x:v>0</x:v>
</x:c>
그 속성이 CellFormats
목록에서 CellFormat
지수 인 StyleIndex
을 의미하는 이 셀의 서식 지정에 해당합니다. 여기에 CellFormats
의 XML 희망이 조금 명확하게하는 것입니다
<x:cellXfs count="2" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<x:xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" />
<x:xf numFmtId="0" fontId="0" fillId="1" borderId="1" xfId="0" />
</x:cellXfs>
을 우리가 CellFormats
요소 인 x:cellXfs
요소가 위의 XML에서 그것은 x:xf
또는 CellFormat
요소의 두 아이가 있습니다. 우리는 우리가 원하는 우리가 의미 CellFormats
요소 아래 첫 번째 인덱스 (또는 두 번째 요소)를 원하는 StyleIndex
속성에서 알이 CellFormat
: 이제 셀의 텍스트를하기 위해 회전
<x:xf numFmtId="0" fontId="0" fillId="1" borderId="1" xfId="0" />
당신이
해야합니다
CellFormat
을 통해 제어하십시오. 다음은 90도 회전으로 CellFormat를 생성하기 위해 사용해야합니다 코드입니다 : 다른 각도로 회전 할 텍스트를 원하는 경우
public CellFormat GenerateCellFormat()
{
CellFormat cellFormat1 = new CellFormat(){ NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyAlignment = true };
Alignment alignment1 = new Alignment(){ TextRotation = (UInt32Value)90U };
cellFormat1.Append(alignment1);
return cellFormat1;
}
다음 당신이에서 원하는 각도로 90U 교체는 -
Cell cell = GetCell(worksheetPart.Worksheet, columnName, rowIndex);
cell.StyleIndex = InsertCellFormat(workbookPart, GenerateCellFormat());
// Helper method to insert the cell format in the CellFormats
public static uint InsertCellFormat(WorkbookPart workbookPart, CellFormat cellFormat)
{
CellFormats cellFormats = workbookPart.WorkbookStylesPart.Stylesheet.Elements<CellFormats>().First();
cellFormats.Append(cellFormat);
return (uint)cellFormats.Count++;
}
복제를 HTTP의 : 90 90 이제
에 당신은
CellFormats
에CellFormat
다음 원하는 셀의StyleIndex
에 새 인덱스가 회전 한 것을 설정하는 것이 삽입해야합니다 // 유래를 .com/questions/605966 6/answer/submit? s = 9219459d-a516-4000-9913-d6d5843fecb7? – emd