Hi,
I’m using setHtmlText to insert an HTML formatted text into a TextBox.
I encoutered an issue I manage to bypass : multiple space char (" ") should be intepreted as one space.
Now a question : After balise, font size provided by Java code source (textbox.getFont().setSize(14) seems to be overwritten by another value I didn’t manage to determine.
Is there any way to control this font size ? (size is the same for all the document)
thanks you
Hi,
Here is code source :
int textboxIndex = sheet.getTextBoxes().add(cellComment.getRow(), cellComment.getColumn(), (int)height, (int)width);
TextBox textbox0 = sheet.getTextBoxes().get(textboxIndex);
textbox0.setHtmlText(str.toString());
textbox0.getFont().setSize(14);
textbox0.setLocked(true);
str is a Stringbuffer build by parsing attached HTML file (rename into .txt)
and the result is the jpg one
Edit : .Cells v7.0.0.3 - JDK 1.4
Hi,
Please see the code below, it will remove all the double spaces. I have also attached the output xlsx and screenshot.
Java
String path = “F:\Shak-Data-RW\Downloads\Output.xlsx”;
String str = " <p style=“margin-top: 0px”> Dear all, <p style=“margin-top: 0px”> <p style=“margin-top: 0px”> As communicated to you in June, the roll-out of SAFIR v3.0 will take place between the end of September and early October. <p style=“margin-top: 0px”> <p style=“margin-top: 0px”> On top of adding com<font color="#ff0000">mitments and enabling the user to generate for each deal the full quarterly review, will incorporate additional credit related information. Most notably, the detailed cash fl<font color="#000000">ow will now be displayed in order to show Free Cash Flow Before Debt Service - with customized details deal b “;
//This code will remove all double spaces
while(str.indexOf(” “)>0)
{
System.out.println(str);
str = str.replaceAll(” ", " “);
int idx = str.indexOf(” ");
System.out.println(idx);
}
Workbook workbook = new Workbook();
Worksheet sheet = workbook.getWorksheets().get(0);
int textboxIndex = sheet.getTextBoxes().add(5, 5, 300, 300);
TextBox textbox0 = sheet.getTextBoxes().get(textboxIndex);
textbox0.setHtmlText(str.toString());
textbox0.getFont().setSize(14);
textbox0.setLocked(true);
workbook.save(path);
Screenshot:
Hi,
Hi,
it still doesn’t works with 7.0.1.2
I attach the simpliest exemple I can do
in test.htm, only “Dear” is bold
when i put it in textbox with aspose “all” is bold too. it shouldn’t
here my code :
Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().get(0);
Cell cellComment = sheet.getCells().get(“A1”);
int textboxIndex = sheet.getTextBoxes().add(cellComment.getRow(), cellComment.getColumn(), 1000, 1000);
TextBox textbox0 = sheet.getTextBoxes().get(textboxIndex);
StringBuffer str = new StringBuffer();
BufferedReader br = new BufferedReader(new FileReader(“c:\test.htm”));
String line;
while ((line=br.readLine()) != null){
str.append(line);
}
br.close();
textbox0.getFont().setSize(14);
textbox0.setHtmlText(str.toString());
textbox0.setLocked(true);
MsoTextFrame textframe0 = textbox0.getTextFrame();
textframe0.setAutoSize(false);
book.save(“c:\out.xls”, FileFormatType.EXCEL_97_TO_2003);
Kind regards
Well, I just have done some more test
Dear all : works fine
Dear all : doesn’t work
It seems, while parsing the line, aspose search the last closing tag, even if another closing tag has been found before. But the closing tag must correspond to an opening one, for exemple :
Dear all test
“test” will not be bold, because the last closing tag do not correspond to an opening one.
It’s the only logic I have found.
Hi,
I have run your code and you are right. To illustrate, I have attached my code and the output and screenshot.
We have logged this issue. We will fix it asap and update you.
This issue has been logged as CELLSJAVA-30911.
Java
String path = “F:\Shak-Data-RW\Downloads\output.xls”;
String str = " <p style=“margin-top: 0px”> Dear all ";
Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().get(0);
Cell cellComment = sheet.getCells().get(“A1”);
int textboxIndex = sheet.getTextBoxes().add(cellComment.getRow(), cellComment.getColumn(), 1000, 1000);
TextBox textbox0 = sheet.getTextBoxes().get(textboxIndex);
textbox0.getFont().setSize(14);
textbox0.setHtmlText(str.toString());
textbox0.setLocked(true);
MsoTextFrame textframe0 = textbox0.getTextFrame();
textframe0.setAutoSize(false);
book.save(path + “.out.xls”, FileFormatType.EXCEL_97_TO_2003);
Screenshot:
Hi,
It’s better but still not usable for production use :
While exporting to PDF format, a space is insert at each style change.
Breakline isn’t ok.
neither Underline
Please see atchament for exemple
Workbook workbook = new Workbook(“c:\src.xls”);
workbook.save(“c:\out.pdf”, FileFormatType.PDF);
made with v7.0.1.5, JDK 1.4
Hi,
The issues you have found earlier (filed as 30911) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.