Aggiunta di HTML Rich Text all'interno di Cell
Aspose.Cells supporta la conversione di Microsoft orientato a Excel HTML nel formato XLS/XLSX. Significa che lo HTML generato da Microsoft Excel può essere riconvertito nel formato XLS/XLSX utilizzando Aspose.Cells.
Allo stesso modo, se c’è un semplice HTML, Aspose.Cells può convertirlo in HTML Rich Text. Aspose.Cells fornisceCell.setHtmlString() proprietà che può prendere un semplice HTML e convertirlo in testo di cella formattato.
Esempio
Lo screenshot seguente mostra il file Excel di output generato con Aspose.Cells. Come puoi vedere, mostra il rich text formattato HTML aggiunto all’interno della cella A1 utilizzando ilCell.setHtmlString()proprietà.
Questo è il codice di esempio che ha generato il file Excel di output come mostrato nello screenshot sopra.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
String dataDir = Utils.getDataDir(AddImageHyperlinks.class); | |
// Instantiate a new workbook | |
Workbook workbook = new Workbook(); | |
// Get the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Insert a string value to a cell | |
worksheet.getCells().get("C2").setValue("Image Hyperlink"); | |
// Set the 4th row height | |
worksheet.getCells().setRowHeight(3, 100); | |
// Set the C column width | |
worksheet.getCells().setColumnWidth(2, 21); | |
// Add a picture to the C4 cell | |
int index = worksheet.getPictures().add(3, 2, 4, 3, dataDir + "aspose-logo.jpg"); | |
// Get the picture object | |
com.aspose.cells.Picture pic = worksheet.getPictures().get(index); | |
// Set the placement type | |
pic.setPlacement(PlacementType.FREE_FLOATING); | |
// Add an image hyperlink | |
pic.addHyperlink("http://www.aspose.com/"); | |
com.aspose.cells.Hyperlink hlink = pic.getHyperlink(); | |
// Specify the screen tip | |
hlink.setScreenTip("Click to go to Aspose site"); | |
// Save the Excel file | |
workbook.save(dataDir + "ImageHyperlink.xls"); |