Commit Graph

88 Commits

Author SHA1 Message Date
Ivan
c2419f3896 Code Inspector improvements
Change coding issues raised by code inspector.
Still some remain to fix.
2014-03-18 10:34:13 -05:00
chrassig
55ac5af43b More sophisticated calculation of cell widths
Let me start by saying we really love the ABAP2XLSX project. Compared to exporting CSV files and importing them to Excel, it makes transferring data from SAP systems to Excel and vice versa so much easier.

What we did not like so far was the optimization of column width, especially because of the way this is realized in the XLSX file format (why did they not just add an attribute "optimize column width = true"?). Anyway, ABAP2XLSX being an open source project, we decided to try to bring some progress to this feature.

We ended up rewriting the method CALCULATE_CELL_WIDTH of the class ZCL_EXCEL_WORKSHEET.

We added the following features:
a) Before, the calculation of the cell width in ABAP2XLSX did not take into account the fact that Excel uses a proportional font by default. Thus, columns with many "i"s ended up too wide, while columns containing many "W"s ended up not wide enough.

We now use the function module LOAD_FONT, contained in SAP package BC. Thus, it should be available in pretty much every SAP system that runs ABAP. LOAD_FONT returns an internal table containing the width of every letter known in a font. You can upload Excel's default font Calibri using transaction SM73. Make sure to upload all four files (standard, bold, italic, bold and italic) and to use the description "Calibri", i.e. exactly the name Excel displays for the font. If you want to use other fonts in your files created by ABAP2XLSX, you can of course upload other fonts as well.

We calculate the sum of the widths of all characters in a cell, and add some cell padding, similar to the way Excel does it. If the font is not available in your SAP system, we revert back to a logic similar to the old one.

As calling LOAD_FONT for every cell took several seconds when we tested with larger tables, we store the values read from the function in a hash table. Thus, we only have to call the function once for every combination of font name and font attributes used in your Excel file.

b) XLSX stores dates in a cryptic format. For dates, the current implementation calculates the width of the cryptic values, thus, the columns end up too narrow.

Fortunately, ABAP2XLSX already contains a method to transform the cryptic value into an ABAP date. We then use ABAP's WRITE statement to create a date in the format the user is preferring, and calculate the width of this formatted date.

c) ABAP2XLSX currently does not consider auto filters. Thus, a column may end up too narrow, not showing the complete header text.

We fixed this by adding a fixed value to the cell width if an auto filter is activated. We use a fixed value because the size of the auto filter button in Excel does not depend on the font size you use.

d) ABAP2XLSX only estimates the width of the characters. Excel adds a small fixed amount to the width of the characters to create some horizontal cell padding. We added cell padding as well, as this brought the cell width even closer to the values calculated by Excel.

e) ABAP2XLSX already uses ABAP's data type FLOAT to store the width of a cell. However, CALCULATE_CELL_WIDTH used data type I (integer) to calculate the cell width before. Changing the parameter type for the parameter EP_WIDTH from I to FLOAT, and adjusting the variable used by the calling method CALCULATE_COLUMN_WIDTHS in the same way, made the calculation even more precise.
2014-03-14 16:15:09 +01:00
Ivan
111cf14f2d Fix issue #297 2014-03-05 14:00:00 -06:00
Ivan Femia
427ca5c4d8 Fixed #291
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@433 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-09-16 23:17:04 +00:00
Ivan Femia
5c6995fe90 Test #290
It is possible to specify a formula in the field catalog instead of a value (BIND_TABLE)

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@432 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-09-11 22:07:48 +00:00
Stefan Schmöcker
efedac0571 #284: Added support of reading XLSX-Files where the formulae are not stated explicitly but by reference to another cell holding a reference formula. Thanks to David for supplying the method to shift a formula to another cell.
Enhanced Demoreport 6 to demonstrate how this new method can be used in other circumstances then reading in an EXCEL-sheet


set to test #268:  Changed unit-test to make use of the extended functionality in ZCX_EXCEL

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@428 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-08-11 10:43:02 +00:00
Ivan Femia
e6ce67fc32 Fix an error with not characters values in set_cell method (issue #162)
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@417 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-04-09 08:01:05 +00:00
Ivan Femia
9528905a07 ready to test #162 Adding Stefan suggestion and adapting DEMO14
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@415 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-04-07 11:38:55 +00:00
Ivan Femia
7d5635ec6d Ready to test #259 Fix in classes ZCL_EXCEL_AUTOFILTERS, ZCL_EXCEL_AUTOFILTER, ZCL_EXCEL_WORKSHEET, ZCL_EXCEL_WRITER_2007 and ZCL_EXCEL_CONVERTER
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@413 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2013-04-07 10:06:59 +00:00
Stefan Schmöcker
70e0659f82 ZCL_EXCEL_WORKSHEET=>SET_TITLE
#243 : ' not allowed as first character in title of worksheet
#230 : pimp my code

also readded implementing code of interface printsettings since it seems to have been eradicated when removing the aliases

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@399 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-08 13:11:29 +00:00
Alessandro Iannacci
8612883c9a Issue #240 - Aliases (added with commit #378) removed
+
daily build including all fixes

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@394 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-06 10:37:18 +00:00
Alessandro Iannacci
5c9dde9b26 Corrupted slinkee corrected
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@392 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-06 09:51:45 +00:00
Alessandro Iannacci
408a280c2a #386 file corrupted --> re-added
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@388 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-05 12:06:33 +00:00
Alessandro Iannacci
8fb4ca103e git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@387 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 2012-12-05 12:05:41 +00:00
Alessandro Iannacci
186cd05881 changeset #378 --> re-added, sorry
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@386 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-05 11:53:02 +00:00
Alessandro Iannacci
9ec17f9a2a #236: feature completed
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@385 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-05 11:46:37 +00:00
Stefan Schmöcker
e7865e58cb set to test #235 - Print - Titles: Repeatable Rows and Columns
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@378 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-02 14:15:32 +00:00
Stefan Schmöcker
14699b93ab leave at test #227 because of minor cosmetic changes
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@376 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-01 21:07:48 +00:00
Alessandro Iannacci
1b0a69d2b3 #227
Bind Table: Overlapping tables should raise exception - FIXED

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@375 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-12-01 18:08:28 +00:00
Alessandro Iannacci
8c45483af8 git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@370 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049 2012-11-29 09:00:09 +00:00
Ivan Femia
fda6f0e3eb Ready to test #163
Added range capability to worksheet

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@358 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-11-04 22:22:46 +00:00
Stefan Schmöcker
5d1bfcc2d8 Issue #225 - Correction BIND_ALV_OLE2
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@349 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-10-28 23:25:22 +00:00
Stefan Schmöcker
83269343a6 fix #226 - change of sheet title invalidates named ranges referring to this sheet
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@348 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-10-28 20:43:03 +00:00
Stefan Schmöcker
6e902d884b #179 - Add coloring of worksheet tabs ready for testing. Reader & Writer updated
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@345 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-10-23 22:23:45 +00:00
Rene Turnheim
a200b573e7 Fixed #202 issue. Added hex type to string conversion case for excel. As hex data type is not supported by Excel.
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@334 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-08-29 01:15:10 +00:00
Ivan Femia
485a7e8655 Ready to test #204 #187 #188
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@328 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-08-26 16:28:49 +00:00
Rene Turnheim
4ab796ff90 Issue #177 resolved.
Also cleaned missing exception class zcx_excel for some methods.
This change closes #177. 

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@325 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-08-10 16:21:31 +00:00
Rene Turnheim
895b5a3fb3 Issue #171 resolved. Also clean missing exception class for some methods.
This change closes #171.

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@324 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-08-10 15:55:44 +00:00
Ivan Femia
a47aea4833 Small changes to descriptions
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@317 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-06-30 20:03:35 +00:00
Ivan Femia
892d7e7cd0 ready to test
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@316 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-06-30 19:49:06 +00:00
Gregor Wolf
c3c4021446 Fixed problem introduced with Changeset 302 to fix issue #163.
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@315 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-06-29 14:27:31 +00:00
Rene Turnheim
f05f725862 issue #171 ready for testing;
New method GET_DEFAULT_EXCEL_TIME_FORMAT created.

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@313 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-05-06 22:17:37 +00:00
Ivan Femia
4ea14eee0e Fix a bug introduced with commit for issue #163
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@302 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-04-25 15:23:32 +00:00
Ivan Femia
327ef3f5f6 Ready to test #151
As for OXML specification value should be a string value
- ZCL_EXCEL_WORKSHEET only pretty printer -

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@298 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-04-25 09:27:53 +00:00
Stefan Schmöcker
b47788b58e Issue #157, 2nd topic:Allow default styles for columns, sheet or whole document
Added demoreport 36 to demonstrate this

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@292 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-04-04 22:03:54 +00:00
Stefan Schmöcker
b1d6654f42 Issue #157 - Adding methods set_row_height and set_column_width to ZCL_EXCEL_WORKSHEET
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@291 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-04-02 20:21:39 +00:00
Stefan Schmöcker
9ca303b3c1 Issue #155 - less strict typing of parameters. This time: ip_column set from ZEXCEL_CELL_COLUMN_ALPHA to SIMPLE
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@290 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-04-02 14:10:16 +00:00
Ivan Femia
2f8023e37a Changed method GENERATE_TITLE in order to use textpools
!!! Import using latest version of SAPLINK plugin ZSAPLINK_CLASS !!!

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@288 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-03-31 14:13:21 +00:00
Stefan Schmöcker
a2ca172cf0 Issue #154 - Worksheet names ( generation if not passed and checks for uniqueness and allowed characters )
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@284 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-03-27 22:46:07 +00:00
Stefan Schmöcker
57867439aa #152 - ZCL_EXCEL_WORKSHEET->SET_CELL: Don't touch existing style if only value is passed
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@283 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-03-26 22:58:40 +00:00
Ivan Femia
9ca5bcfcca Fixed #150
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@277 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-03-23 22:50:58 +00:00
Ivan Femia
f6febd8a5c Ready to test #139
Changed methods RECURSIVE_CLASS_TO_STRUCT and RECURSIVE_STRUCT_TO_CLASS, now in class ZCL_EXCEL_COMMON
Deleted method CREATE_AUTOFILTER, now included in CREATE_XL_SHEET
Moved method ADD_STATIC_STYLES from method ZIF_EXCEL_WRITER~WRITE_FILE of class ZCL_EXCEL_WRITER_2007/ZCL_EXCEL_WRITER_XLSM to method CREATE
Renamed ZDEMO_EXCEL2A in ZDEMO_EXCEL34
Renamed ZDEMO_EXCEL2B in ZDEMO_EXCEL35
Added demos in ZDEMO_EXCEL (Demo Collection)

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@270 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-03-19 21:46:37 +00:00
Rene Turnheim
0e89946359 Fixed #138. DEMO30 and DEMO09 work now with the new solution.
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@260 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-02-18 13:01:13 +00:00
Rene Turnheim
57902fcc78 Fixed is default values for zoom #140 and error introduced with get_value_type method #138
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@257 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-02-15 01:54:08 +00:00
Rene Turnheim
8e2fee3389 New method get_value_type created and it will get executed in set_cell, if ip_abap_type is not supplied.
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@255 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-02-09 12:20:48 +00:00
Ivan Femia
3397d0ac6c Fiz issue #135
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@251 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-01-20 20:45:45 +00:00
Ivan Femia
6d0a0eb44f Fixed issue #91, great job by Rene Turnheim
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@250 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2012-01-20 20:33:22 +00:00
Gregor Wolf
b146c57818 ready to test #120
Thanks to Stefan Schmöcker for the contribution of a sample report and the improvements.

git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@229 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2011-12-07 23:35:11 +00:00
Ivan Femia
1ef3613bf8 Fix issue #121
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@225 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2011-11-01 09:53:48 +00:00
Ivan Femia
bd614113a7 ZoomScale support demo23 updated - thanks to Alessandro Iannacci for the idea( @Gh14Cc10 )
git-svn-id: https://subversion.assembla.com/svn/abap2xlsx/trunk@216 b7d68dce-7c3c-4a99-8ce0-9ea847f5d049
2011-08-25 19:52:28 +00:00