public void TestGetFonts() { XSSFRichTextString rt = new XSSFRichTextString(); XSSFFont font1 = new XSSFFont(); font1.FontName = ("Arial"); font1.IsItalic = (true); rt.Append("The quick", font1); XSSFFont font1FR = (XSSFFont)rt.GetFontOfFormattingRun(0); Assert.AreEqual(font1.IsItalic, font1FR.IsItalic); Assert.AreEqual(font1.FontName, font1FR.FontName); XSSFFont font2 = new XSSFFont(); font2.FontName = ("Courier"); font2.IsBold = (true); rt.Append(" brown fox", font2); XSSFFont font2FR = (XSSFFont)rt.GetFontOfFormattingRun(1); Assert.AreEqual(font2.IsBold, font2FR.IsBold); Assert.AreEqual(font2.FontName, font2FR.FontName); }
public void TestBug56511_values() { XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("56511.xlsx"); ISheet sheet = wb.GetSheetAt(0); IRow row = sheet.GetRow(0); // verify the values to ensure future Changes keep the returned information equal XSSFRichTextString rt = (XSSFRichTextString)row.GetCell(0).RichStringCellValue; Assert.AreEqual(0, rt.NumFormattingRuns); Assert.IsNull(rt.GetFontOfFormattingRun(0)); Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(0)); rt = (XSSFRichTextString)row.GetCell(1).RichStringCellValue; Assert.AreEqual(0, row.GetCell(1).RichStringCellValue.NumFormattingRuns); Assert.IsNull(rt.GetFontOfFormattingRun(1)); Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(1)); rt = (XSSFRichTextString)row.GetCell(2).RichStringCellValue; Assert.AreEqual(2, rt.NumFormattingRuns); Assert.IsNotNull(rt.GetFontOfFormattingRun(0)); Assert.AreEqual(4, rt.GetLengthOfFormattingRun(0)); Assert.IsNotNull(rt.GetFontOfFormattingRun(1)); Assert.AreEqual(9, rt.GetLengthOfFormattingRun(1)); Assert.IsNull(rt.GetFontOfFormattingRun(2)); rt = (XSSFRichTextString)row.GetCell(3).RichStringCellValue; Assert.AreEqual(3, rt.NumFormattingRuns); Assert.IsNull(rt.GetFontOfFormattingRun(0)); Assert.AreEqual(1, rt.GetLengthOfFormattingRun(0)); Assert.IsNotNull(rt.GetFontOfFormattingRun(1)); Assert.AreEqual(3, rt.GetLengthOfFormattingRun(1)); Assert.IsNotNull(rt.GetFontOfFormattingRun(2)); Assert.AreEqual(9, rt.GetLengthOfFormattingRun(2)); }
public void TestBug56511() { XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("56511.xlsx"); foreach (XSSFSheet sheet in wb) { int lastRow = sheet.LastRowNum; for (int rowIdx = sheet.FirstRowNum; rowIdx <= lastRow; rowIdx++) { XSSFRow row = sheet.GetRow(rowIdx) as XSSFRow; if (row != null) { int lastCell = row.LastCellNum; for (int cellIdx = row.FirstCellNum; cellIdx <= lastCell; cellIdx++) { XSSFCell cell = row.GetCell(cellIdx) as XSSFCell; if (cell != null) { //System.out.Println("row " + rowIdx + " column " + cellIdx + ": " + cell.CellType + ": " + cell.ToString()); XSSFRichTextString richText = cell.RichStringCellValue as XSSFRichTextString; int anzFormattingRuns = richText.NumFormattingRuns; for (int run = 0; run < anzFormattingRuns; run++) { /*XSSFFont font =*/ richText.GetFontOfFormattingRun(run); //System.out.Println(" run " + run // + " font " + (font == null ? "<null>" : font.FontName)); } } } } } } }
public void TestGetFonts() { XSSFRichTextString rt = new XSSFRichTextString(); XSSFFont font1 = new XSSFFont(); font1.FontName = ("Arial"); font1.IsItalic = (true); rt.Append("The quick", font1); XSSFFont font1FR = (XSSFFont)rt.GetFontOfFormattingRun(0); Assert.AreEqual(font1.IsItalic, font1FR.IsItalic); Assert.AreEqual(font1.FontName, font1FR.FontName); XSSFFont font2 = new XSSFFont(); font2.FontName = ("Courier"); font2.IsBold = (true); rt.Append(" brown fox", font2); XSSFFont font2FR = (XSSFFont)rt.GetFontOfFormattingRun(1); Assert.AreEqual(font2.IsBold, font2FR.IsBold); Assert.AreEqual(font2.FontName, font2FR.FontName); }