Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Get Rich Inline Text
The following example shows you how to get text from RichTextInline.
import com.independentsoft.office.spreadsheet.Cell; import com.independentsoft.office.spreadsheet.RichTextInline; import com.independentsoft.office.spreadsheet.Run; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Workbook book = new Workbook("c:\\test\\input.xlsx"); Worksheet sheet1 = (Worksheet)book.getSheets().get(0); Cell b1 = sheet1.get("B1"); String text = ""; if(b1.getRichTextInline() != null) { RichTextInline inlineText = b1.getRichTextInline(); for(Run run : inlineText.getRuns()) { if(run.getText() != null && run.getText().getValue() != null) { text += run.getText().getValue(); } } System.out.println(text); } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*