-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnumber-formats.sql
47 lines (35 loc) · 1.24 KB
/
number-formats.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
declare
ctxId ExcelGen.ctxHandle;
sheet1 ExcelGen.sheetHandle;
sheet2 ExcelGen.sheetHandle;
rc sys_refcursor;
begin
ctxId := ExcelGen.createContext(ExcelGen.FILE_XLSX);
open rc for
select sysdate D1
, sysdate D2
, 1 N1
, 1.26 N2
, systimestamp T1
, systimestamp T2
from dual ;
sheet1 := ExcelGen.addSheetFromCursor(ctxId, 'a', rc);
ExcelGen.setHeader(ctxId, sheet1);
-- column #1 format
ExcelGen.setColumnFormat(ctxId, sheet1, 1, 'dd/mm/yyyy');
-- column #4 format
ExcelGen.setColumnFormat(ctxId, sheet1, 4, '0.0');
-- column #5 format
ExcelGen.setColumnFormat(ctxId, sheet1, 5, 'dd/mm/yyyy hh:mm:ss');
-- default sheet-level date format
ExcelGen.setDateFormat(ctxId, sheet1, 'yyyy-mm');
-- default sheet-level number format
ExcelGen.setNumFormat(ctxId, sheet1, '0.00');
-- default sheet-level timestamp format
ExcelGen.setTimestampFormat(ctxId, sheet1, 'hh:mm:ss.000');
-- another sheet with default wookbook-level formats
sheet2 := ExcelGen.addSheetFromQuery(ctxId, 'b', 'select sysdate D1, 12345 N1, systimestamp T1 from dual');
ExcelGen.createFile(ctxId, 'TEST_DIR', 'number-formats.xlsx');
ExcelGen.closeContext(ctxId);
end;
/