-
Notifications
You must be signed in to change notification settings - Fork 294
Enabling rich text comments #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am currently fixing this on our system. The cause is that method |
I am currently adding rich text functionality to the comments. |
Hi Sandra, in your comment to PR #1297 you mentioned
As for the italian texts: we don't want them either, but they are present in the main branch of abap2xlsx/abap2xlsx , unfortunately. I have closed PR #1297 and work with PR #1298 meanwhile, which doesn't contain these texts. But they should be removed sometime from the main repo, maybe with a dedicated issue. As for the default parameters as constants: this is indeed part of the development. Changes concerning the usage of comments
Changes needed for reading and saving comments
Minor refactorings on the way
Best regards, |
As I already said, it's difficult to review a PR with many improvements unrelated to the issue. The right way is to keep PRs small, i.e. make one PR for each fix and each enhancement, one PR for each kind of refactoring (no change in feature). If you don't do it, I'll create a PR with the enhancements, and then we'll take care of the fix. Note that I appreciate a lot your participation, I don't want to refrain you from proposing solutions, it's only to make the work easier for me and other reviewers. |
I understood this, and this is why I have closed the PR #1297 . PR #1298 only contains the changes necessary for enabling RTF comments. I have described these changes in the last comment of this issue. |
I guess we should try to gain some benefits from the existing RTF functionality that we know from worksheet's method set_cell. Even three times in the reader because inlineStr is a tag that could contain richt text, too And then we can create a ZDEMO_EXCEL48 like this: REPORT zdemo_excel48.
DATA:
lo_excel TYPE REF TO zcl_excel,
lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_style TYPE REF TO zcl_excel_style,
lo_comment TYPE REF TO zcl_excel_comment,
lv_value TYPE string,
lt_rtf TYPE zexcel_t_rtf,
ls_rtf LIKE LINE OF lt_rtf,
ls_font LIKE ls_rtf-font.
CONSTANTS:
gc_save_file_name TYPE string VALUE '48_MultipleStylesInOneCell.xlsx'.
INCLUDE zdemo_excel_outputopt_incl.
START-OF-SELECTION.
CREATE OBJECT lo_excel.
lo_worksheet = lo_excel->get_active_worksheet( ).
lo_style = lo_excel->add_new_style( ).
ls_font = lo_style->font->get_structure( ). "Default settings from ZCL_EXCEL_STYLE_FONT's Constructor
lv_value = 'normal red underline normal red-underline bold italic bigger Times-New-Roman'.
" red
ls_rtf-font = ls_font.
ls_rtf-font-color-rgb = zcl_excel_style_color=>c_red.
ls_rtf-offset = 7.
ls_rtf-length = 3.
INSERT ls_rtf INTO TABLE lt_rtf.
" underline
ls_rtf-font = ls_font.
ls_rtf-font-underline = abap_true.
ls_rtf-font-underline_mode = zcl_excel_style_font=>c_underline_single.
ls_rtf-offset = 11.
ls_rtf-length = 9.
INSERT ls_rtf INTO TABLE lt_rtf.
" red and underline
ls_rtf-font = ls_font.
ls_rtf-font-color-rgb = zcl_excel_style_color=>c_red.
ls_rtf-font-underline = abap_true.
ls_rtf-font-underline_mode = zcl_excel_style_font=>c_underline_single.
ls_rtf-offset = 28.
ls_rtf-length = 13.
INSERT ls_rtf INTO TABLE lt_rtf.
" bold
ls_rtf-font = ls_font.
ls_rtf-font-bold = abap_true.
ls_rtf-offset = 42.
ls_rtf-length = 4.
INSERT ls_rtf INTO TABLE lt_rtf.
" italic
ls_rtf-font = ls_font.
ls_rtf-font-italic = abap_true.
ls_rtf-offset = 47.
ls_rtf-length = 6.
INSERT ls_rtf INTO TABLE lt_rtf.
" bigger
ls_rtf-font = ls_font.
ls_rtf-font-size = 28.
ls_rtf-offset = 54.
ls_rtf-length = 6.
INSERT ls_rtf INTO TABLE lt_rtf.
" Times-New-Roman
ls_rtf-font = ls_font.
ls_rtf-font-name = zcl_excel_style_font=>c_name_roman.
ls_rtf-font-scheme = zcl_excel_style_font=>c_scheme_none.
ls_rtf-font-family = zcl_excel_style_font=>c_family_roman.
" Create an underline double style
ls_rtf-font-underline = abap_true.
ls_rtf-font-underline_mode = zcl_excel_style_font=>c_underline_double.
ls_rtf-offset = 61.
ls_rtf-length = 15.
INSERT ls_rtf INTO TABLE lt_rtf.
lo_worksheet->set_cell(
ip_column = 'B'
ip_row = 2
ip_style = lo_style->get_guid( )
ip_value = lv_value
it_rtf = lt_rtf ).
lo_comment = lo_excel->add_new_comment( ).
lo_comment->set_text( ip_ref = 'B2'
ip_text = lv_value
it_rtf = lt_rtf
ip_right_column = 12
ip_bottom_row = 10 ).
lo_worksheet->add_comment( lo_comment ).
*** Create output
lcl_output=>output( lo_excel ). with the following result: 48_MultipleStylesInOneCell_with_comment.xlsx And of course i can read Rüdiger's example excel, but the comment gets the standard box with the shadow, that we know from ABAP2XLSX. I guess that is sufficient. If you agree with this solution i would propose this soon in at least two steps:
|
Current PR #1298. I agree with @darnoc312 that it's best to reuse and put in common abap2xlsx/src/zcl_excel_worksheet.clas.abap Lines 1949 to 2002 in 9fde392
|
This is one followup of issue #1293.
The pure text content of a cell comment is not always completely read by the reader class
ZCL_EXCEL_READER_2007
, if the comment contains formatted parts.Even when respecting the current restriction of the reader that rich text formatting is not supported for comments, we should at least get the complete pure text content of the comment (i.e. the concatenation of all its, possibly differently formatted parts).
For example, consider the following comment:
After reading the Excel with class
ZCL_EXCEL_READER_2007
, theget_text( )
method of the comment object in thecomments
collection of the worksheet object will yield only the first part of the comment, namely the textInfo:
It should give the string
Info:\nFür jeden...
Since for achieving this, the parsing of RTF data in the comments part of the Excel file is necessary anyway, I decided to fully implement RTF functionality for comments for reading and writing.
To reproduce the problem:
ZDEMO_EXCEL37
to readnotes.xlsx
and write to a new file. Debug the methodget_text
ofZCL_EXCEL_COMMENT
for the comment of cellA1
to see the problem.The text was updated successfully, but these errors were encountered: