Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mortenbra/alexandria-plsql-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenbra committed Oct 2, 2019
2 parents 197866b + c8f024b commit ada4875
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
8 changes: 5 additions & 3 deletions ora/ooxml_util_pkg.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ begin
Who Date Description
------ ---------- --------------------------------
JMW 02.03.2016 Created
JMW 31.03.2017 Added a 'state' attribute to t_xlsx_sheet_properties
JMW 12.04.2018 Removed the ORDER BY clause

*/

Expand All @@ -87,9 +89,9 @@ begin
columns
r_id varchar2(255) path '@r:id',
sheetid number path '@sheetId',
name varchar2(31) path '@name' ) xml
where xml.r_id is not null
order by xml.sheetid;
name varchar2(31) path '@name',
state varchar2(10) path '@state' ) xml
where xml.r_id is not null;

return l_returnvalue;

Expand Down
4 changes: 3 additions & 1 deletion ora/ooxml_util_pkg.pks
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ as
------ ---------- --------------------------------
MBR 25.01.2011 Created
MBR 11.07.2011 Added Powerpoint-specific features
JMW 31.03.2017 Added a 'state' attribute to t_xlsx_sheet_properties

*/

Expand Down Expand Up @@ -81,7 +82,8 @@ as
type t_xlsx_sheet_attributes is record (
r_id varchar2(255),
sheetid number,
name varchar2(31)
name varchar2(31),
state varchar2(10)
);

type t_xlsx_sheet_properties is table of t_xlsx_sheet_attributes index by pls_integer;
Expand Down
55 changes: 43 additions & 12 deletions ora/xlsx_builder_pkg.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,15 @@ as
is
t_sheet pls_integer := nvl( p_sheet, workbook.sheets.count() );
begin
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := p_value;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := null;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := get_XfId( t_sheet, p_col, p_row, p_numFmtId, p_fontId, p_fillId, p_borderId, p_alignment );
if p_value is not null
then
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := p_value;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := null;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := get_XfId( t_sheet, p_col, p_row, p_numFmtId, p_fontId, p_fillId, p_borderId, p_alignment );
elsif workbook.sheets( t_sheet ).rows( p_row ).exists( p_col )
then
workbook.sheets( t_sheet ).rows( p_row ).delete( p_col );
end if;
end;
--
function add_string( p_string varchar2 )
Expand All @@ -685,6 +691,19 @@ as
workbook.str_cnt := workbook.str_cnt + 1;
return t_cnt;
end;
--
function clean_string (p_string in varchar2)
return varchar2
is
invalid_ascii constant varchar2(32) :=
chr(00)||chr(01)||chr(02)||chr(03)||chr(04)||chr(05)||chr(06)||chr(07)||
chr(08)|| chr(11)||chr(12)|| chr(14)||chr(15)||
chr(16)||chr(17)||chr(18)||chr(19)||chr(20)||chr(21)||chr(22)||chr(23)||
chr(24)||chr(25)||chr(26)||chr(27)||chr(28)||chr(29)||chr(30)||chr(31)
;
begin
return translate(translate( p_string, invalid_ascii, chr(1)), chr(0)||chr(1), ' ');
end;
--
procedure cell
( p_col pls_integer
Expand All @@ -701,12 +720,18 @@ as
t_sheet pls_integer := nvl( p_sheet, workbook.sheets.count() );
t_alignment tp_alignment := p_alignment;
begin
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := add_string( p_value );
if t_alignment.wrapText is null and instr( p_value, chr(13) ) > 0
if p_value is not null
then
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := add_string( clean_string( p_value ));
if t_alignment.wrapText is null and instr( p_value, chr(13) ) > 0
then
t_alignment.wrapText := true;
end if;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := 't="s" ' || get_XfId( t_sheet, p_col, p_row, p_numFmtId, p_fontId, p_fillId, p_borderId, t_alignment );
elsif workbook.sheets( t_sheet ).rows( p_row ).exists( p_col )
then
t_alignment.wrapText := true;
workbook.sheets( t_sheet ).rows( p_row ).delete( p_col );
end if;
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := 't="s" ' || get_XfId( t_sheet, p_col, p_row, p_numFmtId, p_fontId, p_fillId, p_borderId, t_alignment );
end;
--
procedure cell
Expand Down Expand Up @@ -749,11 +774,17 @@ as
t_ind pls_integer;
t_sheet pls_integer := nvl( p_sheet, workbook.sheets.count() );
begin
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := add_string( nvl( p_value, p_url ) );
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := 't="s" ' || get_XfId( t_sheet, p_col, p_row, '', get_font( 'Calibri', p_theme => 10, p_underline => true ) );
t_ind := workbook.sheets( t_sheet ).hyperlinks.count() + 1;
workbook.sheets( t_sheet ).hyperlinks( t_ind ).cell := alfan_col( p_col ) || p_row;
workbook.sheets( t_sheet ).hyperlinks( t_ind ).url := p_url;
if nvl( p_value, p_url ) is not null
then
workbook.sheets( t_sheet ).rows( p_row )( p_col ).value := add_string( clean_string( nvl( p_value, p_url )));
workbook.sheets( t_sheet ).rows( p_row )( p_col ).style := 't="s" ' || get_XfId( t_sheet, p_col, p_row, '', get_font( 'Calibri', p_theme => 10, p_underline => true ) );
t_ind := workbook.sheets( t_sheet ).hyperlinks.count() + 1;
workbook.sheets( t_sheet ).hyperlinks( t_ind ).cell := alfan_col( p_col ) || p_row;
workbook.sheets( t_sheet ).hyperlinks( t_ind ).url := p_url;
elsif workbook.sheets( t_sheet ).rows( p_row ).exists( p_col )
then
workbook.sheets( t_sheet ).rows( p_row ).delete( p_col );
end if;
end;
--
procedure comment
Expand Down

0 comments on commit ada4875

Please sign in to comment.