Quantcast
Channel: Comments on: Create an Excel-file with PL/SQL
Viewing all articles
Browse latest Browse all 73

By: euelvis

$
0
0

Mike,

You can try something like this in your code:
Worked for me in XE 10g(not tested for complex formulas or different return type).
I hope is useful.

—————————————————————————
/*
–Simple test calls:
as_xlsx.cell(1,1,”,p_type => ‘f’, p_formula => ‘B1+C1′ );
or
as_xlsx.cell(1,1,”,p_type => ‘f’, p_formula => ‘SUM(B1:C1)’ );
*/
—————————————————————————

while t_col_ind is not null
loop
/*Start 14-sep-2013*/
IF workbook.sheets(s).rows(t_row_ind)(t_col_ind).type = ‘f’ THEN
/*
SUM(B1:C1)
10
*/
declare
l_type varchar2(30):=’t=”array”‘;
begin
t_cell := ”
|| ”
|| workbook.sheets(s).rows(t_row_ind)(t_col_ind).formula
|| ”
/* || ”
|| to_char( workbook.sheets( s ).rows( t_row_ind )( t_col_ind ).value, ‘TM9′, ‘NLS_NUMERIC_CHARACTERS=.,’ )
|| ”*/
|| ”;
end;
else
/* End 14-sep-2013 */
t_cell := ”
|| to_char( workbook.sheets( s ).rows( t_row_ind )( t_col_ind ).value, ‘TM9′, ‘NLS_NUMERIC_CHARACTERS=.,’ )
|| ”;
END IF; /* 14-sep-2013 */

if t_len > 32000
then
dbms_lob.writeappend( t_xxx, t_len, t_tmp );
t_tmp := null;
t_len := 0;
end if;
t_tmp := t_tmp || t_cell;
t_len := t_len + length( t_cell );
t_col_ind := workbook.sheets( s ).rows( t_row_ind ).next( t_col_ind );
end loop;

—————————————————————————

instead of :

—————————————————————————

–changes to function finish: loop through cells. Modified t_cell := statment to include tag for forumla
while t_col_ind is not null
loop
t_cell := ”;

if workbook.sheets( s ).rows( t_row_ind )( t_col_ind ).type = ‘f’ then
t_cell := t_cell||”
|| workbook.sheets( s ).rows( t_row_ind )( t_col_ind ).formula
|| ”;
end if;
t_cell := t_cell||”
|| to_char( workbook.sheets( s ).rows( t_row_ind )( t_col_ind ).value, ‘TM9′, ‘NLS_NUMERIC_CHARACTERS=.,’ )
|| ”;
if t_len > 32000
then
dbms_lob.writeappend( t_xxx, t_len, t_tmp );
t_tmp := null;
t_len := 0;
end if;
t_tmp := t_tmp || t_cell;
t_len := t_len + length( t_cell );
t_col_ind := workbook.sheets( s ).rows( t_row_ind ).next( t_col_ind );
end loop;
t_tmp := t_tmp || ”;
t_row_ind := workbook.sheets( s ).rows.next( t_row_ind );
end loop;
—————————————————————————

Nice job Anton.

Best regards,

euelvis


Viewing all articles
Browse latest Browse all 73

Trending Articles