use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project Gargoyle by callakrsos.
the class ExcelUtil method addComment.
/**
* 특정셀에 코멘트를 추가한다.
*
* @param sheet
* @param cell
* @param commentText
* @return
*/
public static void addComment(Sheet sheet, Cell cell, String commentText) {
XSSFDrawing patr = (XSSFDrawing) sheet.createDrawingPatriarch();
Comment comment = patr.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
comment.setString(new XSSFRichTextString(commentText));
cell.setCellComment(comment);
}
use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project cubrid-manager by CUBRID.
the class XlsxReaderHandler method endElement.
/**
* response the event end an element
*
* @param uri the uri of namespace
* @param localName the local name
* @param name the element name
* @throws SAXException the SAXException
*/
public void endElement(String uri, String localName, String name) throws SAXException {
if ("v".equals(name) || "t".equals(name)) {
if (nextIsString) {
try {
int idx = Integer.parseInt(lastContents);
lastContents = new XSSFRichTextString(sharedStringTable.getEntryAt(idx)).toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
String value = lastContents;
if ("".equals(value)) {
return;
}
value = "".equals(value) ? " " : value;
int cols = currentCol - preCol;
if (cols > 1) {
for (int i = 0; i < cols - 1; i++) {
rowlist.add(preCol, "");
}
}
preCol = currentCol;
rowlist.add(currentCol - 1, value);
} else {
if ("row".equals(name)) {
if (rowlist.isEmpty()) {
return;
}
int tmpCols = rowlist.size();
if (currentRow > this.titleRow && tmpCols < this.colsize) {
for (int i = 0; i < this.colsize - tmpCols; i++) {
rowlist.add(rowlist.size(), "");
}
}
try {
operateRows(sheetIndex, rowlist);
} catch (DataFormatException e) {
throw new RuntimeException(e);
} catch (SQLException e) {
throw new RuntimeException(e);
}
if (currentRow == this.titleRow) {
this.colsize = rowlist.size();
}
rowlist.clear();
currentRow++;
currentCol = 0;
preCol = 0;
}
}
}
use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project cubrid-manager by CUBRID.
the class XlsxRowNumberHandler method endElement.
/**
* Response to reading the end of an element
*
* @param uri the uri of namespace
* @param localName the local name
* @param name the element name
* @throws SAXException the SAXException
*/
public void endElement(String uri, String localName, String name) throws SAXException {
if (numberAllRow == 1 && ("v".equals(name) || "t".equals(name))) {
if (nextIsString) {
try {
int idx = Integer.parseInt(contents);
contents = new XSSFRichTextString(sharedStringTable.getEntryAt(idx)).toString();
} catch (Exception e) {
LOGGER.error(e.getMessage());
}
}
String value = contents.trim();
if ("".equals(value)) {
return;
}
value = "".equals(value) ? " " : value;
firstRowLst.add(cols, value);
cols++;
}
}
use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project poi by apache.
the class FillsAndColors method main.
public static void main(String[] args) throws IOException {
//or new HSSFWorkbook();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow(1);
// Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(FillPatternType.BIG_SPOTS);
Cell cell = row.createCell(1);
cell.setCellValue(new XSSFRichTextString("X"));
cell.setCellStyle(style);
// Orange "foreground", foreground being the fill foreground not the font color.
style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell = row.createCell(2);
cell.setCellValue(new XSSFRichTextString("X"));
cell.setCellStyle(style);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("fill_colors.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
}
use of org.apache.poi.xssf.usermodel.XSSFRichTextString in project poi by apache.
the class TestXSSFChartTitle method testExistingChartWithTitle.
@Test
public void testExistingChartWithTitle() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx");
XSSFChart chart = getChartFromWorkbook(wb, "Sheet1");
assertNotNull(chart);
XSSFRichTextString originalTitle = chart.getTitleText();
assertNotNull(originalTitle);
final String myTitle = "My chart title";
assertFalse(myTitle.equals(originalTitle.toString()));
chart.setTitleText(myTitle);
XSSFRichTextString queryTitle = chart.getTitleText();
assertNotNull(queryTitle);
assertEquals(myTitle, queryTitle.toString());
wb.close();
}
Aggregations