本文整理匯總了C#中NPOI.XSSF.UserModel.XSSFFont.SetCharSet方法的典型用法代碼示例。如果您正苦於以下問題:C# XSSFFont.SetCharSet方法的具體用法?C# XSSFFont.SetCharSet怎麽用?C# XSSFFont.SetCharSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NPOI.XSSF.UserModel.XSSFFont
的用法示例。
在下文中一共展示了XSSFFont.SetCharSet方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestCharSet
public void TestCharSet()
{
CT_Font ctFont = new CT_Font();
CT_IntProperty prop = ctFont.AddNewCharset();
prop.val = (FontCharset.ANSI.Value);
ctFont.SetCharsetArray(0, prop);
XSSFFont xssfFont = new XSSFFont(ctFont);
Assert.AreEqual(FontCharset.ANSI.Value, xssfFont.Charset);
xssfFont.SetCharSet(FontCharset.DEFAULT);
Assert.AreEqual(FontCharset.DEFAULT.Value, ctFont.GetCharsetArray(0).val);
// Try with a few less usual ones:
// Set with the Charset itself
xssfFont.SetCharSet(FontCharset.RUSSIAN);
Assert.AreEqual(FontCharset.RUSSIAN.Value, xssfFont.Charset);
// And Set with the Charset index
xssfFont.SetCharSet(FontCharset.ARABIC.Value);
Assert.AreEqual(FontCharset.ARABIC.Value, xssfFont.Charset);
// This one isn't allowed
Assert.AreEqual(null, FontCharset.ValueOf(9999));
try
{
xssfFont.SetCharSet(9999);
Assert.Fail("Shouldn't be able to Set an invalid charset");
}
catch (POIXMLException) { }
// Now try with a few sample files
// Normal charset
XSSFWorkbook workbook = XSSFTestDataSamples.OpenSampleWorkbook("Formatting.xlsx");
Assert.AreEqual(0,
((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset
);
// GB2312 charact Set
workbook = XSSFTestDataSamples.OpenSampleWorkbook("49273.xlsx");
Assert.AreEqual(134,
((XSSFCellStyle)workbook.GetSheetAt(0).GetRow(0).GetCell(0).CellStyle).GetFont().Charset
);
}