使用包 as_xlsx 时,行格式不适用

问题描述 投票:0回答:1

我正在使用 Scheffer 先生的 as_xlsxas_xlsx

一切都很好,但如果我想让我的第一行(我的标题)加粗,它不起作用,我不知道为什么..我没有收到任何错误。

BEGIN
declare sDatum varchar2(10); sDatumFile varchar2(8); sSelect varchar2(2000); 
BEGIN
sDatum:=to_char(LAST_DAY(ADD_MONTHS(sysdate,-1)),'DD.MM.YYYY');
sDatumFile:=to_char(LAST_DAY(ADD_MONTHS(sysdate,-1)),'DDMMYYYY');
select sql_command into sSelect from TABLE_SQL where id=9;
--reset format
as_xlsx.clear_workbook;
--query2sheet
as_xlsx.query2sheet(sSelect); 
--format width & bold
for i in 1 .. 13
loop
as_xlsx.set_column_width( p_col => i, p_width => 10);
end loop;
--this procedure is not working properly
as_xlsx.set_row(p_row => 1, p_fontID => as_xlsx.get_font('Calibri', p_fontsize => 11, p_bold => true), p_alignment => as_xlsx.get_alignment(p_vertical => 'center', p_wraptext => true));
--is working again
as_xlsx.set_column_width( p_col => 2, p_width => 50);
as_xlsx.set_column_width( p_col => 3, p_width => 35);
--save
as_xlsx.save('d:\oracle\exp', 'analysis '||sDatumFile||'.xlsx' ); 
--send
pck_comm.mail_ora_priloha('[email protected]','[email protected]','analysis - to '||sDatum,'analysis to: '||sDatum,'analysis '||sDatumFile||'.xlsx','DIR_EXPORTY');
--delete
utl_file.fremove('d:\oracle\exp', 'analysis '||sDatumFile||'.xlsx');
END;

如果我尝试添加到

as_xlsx.query2sheet(sSelect);
参数
p_sheet=>1
那么一切都是粗体的,我会得到 10 多张。在这些工作表中,列标题单独位于第一行。数据仅在 1 页中。

有什么建议吗?

ps:我用我的列名创建了一个数组,并将

as_xlsx.cell
过程添加到循环中:

for j in 1 .. array.count loop
as_xlsx.cell(p_col =>j, p_row => 1, p_value => array(j), p_fontid =>as_xlsx.get_font('Calibri', p_bold => true),p_alignment =>as_xlsx.get_alignment(p_vertical => 'center', p_wraptext => true) );

在这种情况下,它起作用了。但我仍然不知道,为什么

set_row
不起作用。

oracle plsql oracle11g xlsx
1个回答
0
投票

as_xlsx 命令的排序似乎有问题。用我的数据测试了一下,遇到了和你一样的问题。但是当我创建自己的工作表并 重新排序了步骤,一切正常。

Declare   
    sSelect varchar2(2000); 
Begin
    Select 'Select * From MY_TABLE Order By TAB, PK' Into sSelect From Dual;
    --  1st reset format
        as_xlsx.clear_workbook;

    --  2nd create the sheet
        as_xlsx.new_sheet('TestSheet');

    --  3rd set row 1 bold for your sheet
        as_xlsx.set_row(  p_row => 1, p_fontID => as_xlsx.get_font('Calibri', p_bold => true), p_sheet => 1 );

    --  4th populate sheet with your data
        as_xlsx.query2sheet(p_sql => sSelect, p_sheet => 1); 

    --  5th set column widths
        as_xlsx.set_column_width( p_col => 1, p_width => 20);
        as_xlsx.set_column_width( p_col => 2, p_width => 10);
        as_xlsx.set_column_width( p_col => 3, p_width => 10);
        as_xlsx.set_column_width( p_col => 4, p_width => 10);
        as_xlsx.set_column_width( p_col => 5, p_width => 100);
        as_xlsx.set_column_width( p_col => 6, p_width => 100);
        as_xlsx.set_column_width( p_col => 7, p_width => 10);

    --  6th save
        as_xlsx.save('YOUR DIRECTORY OBJECT NAME', 'analysis.xlsx' ); 
End;

© www.soinside.com 2019 - 2024. All rights reserved.