text
stringlengths
0
234
-- 0040H = Macro sheet
biff_record_identifier: constant array(Excel_type) of Unsigned_16:=
(BIFF2 => 16#0009#,
BIFF3 => 16#0209#,
BIFF4 => 16#0409#
-- BIFF8 => 16#0809#
);
biff_version: constant array(Excel_type) of Unsigned_16:=
(BIFF2 => 16#0200#,
BIFF3 => 16#0300#,
BIFF4 => 16#0400#
-- BIFF8 => 16#0600#
);
begin
WriteBiff(xl,
biff_record_identifier(xl.format),
Intel_16(biff_version(xl.format)) &
Intel_16(Sheet_or_dialogue) &
BOF_suffix
);
end Write_BOF;
-- 5.49 FORMAT (number format)
procedure WriteFmtStr (xl : Excel_Out_Stream'Class; s : String) is
begin
case xl.format is
when BIFF2 | BIFF3 =>
WriteBiff(xl, 16#001E#, To_buf_8_bit_length(s));
when BIFF4 =>
WriteBiff(xl, 16#041E#, (0, 0) & To_buf_8_bit_length(s));
-- when BIFF8 =>
-- WriteBiff(xl, 16#041E#, (0, 0) & -- should be: format index used in other records
-- To_buf_8_bit_length(s));
end case;
end WriteFmtStr;
-- Write built-in number formats (internal)
procedure WriteFmtRecords (xl : Excel_Out_Stream'Class) is
sep_1000: constant Character:= ','; -- US format
sep_deci: constant Character:= '.'; -- US format
-- ^ If there is any evidence of an issue with those built-in separators,
-- we may make them configurable. NB: MS Excel 2002 and 2007 use only
-- the index of built-in formats and discards the strings for BIFF2, but not for BIFF3...
begin
-- 5.12 BUILTINFMTCOUNT
case xl.format is
when BIFF2 =>
WriteBiff(xl, 16#001F#, Intel_16(Unsigned_16(last_built_in - 5)));
when BIFF3 =>
WriteBiff(xl, 16#0056#, Intel_16(Unsigned_16(last_built_in - 3)));
when BIFF4 =>
WriteBiff(xl, 16#0056#, Intel_16(Unsigned_16(last_built_in + 1)));
-- when BIFF8 =>
-- null;
end case;
-- loop & case avoid omitting any choice
for n in Number_format_type'First .. last_custom loop
case n is
when general => WriteFmtStr(xl, "General");
when decimal_0 => WriteFmtStr(xl, "0");
when decimal_2 => WriteFmtStr(xl, "0" & sep_deci & "00"); -- 'Comma' built-in style
when decimal_0_thousands_separator =>
WriteFmtStr(xl, "#" & sep_1000 & "##0");
when decimal_2_thousands_separator =>
WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00");
when no_currency_0 =>
if xl.format >= BIFF4 then
WriteFmtStr(xl, "#" & sep_1000 & "##0;-#" & sep_1000 & "##0");
end if;
when no_currency_red_0 =>
if xl.format >= BIFF4 then
WriteFmtStr(xl, "#" & sep_1000 & "##0;-#" & sep_1000 & "##0");
-- [Red] doesn't go with non-English versions of Excel !!
end if;
when no_currency_2 =>
if xl.format >= BIFF4 then
WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00;" &
"-#" & sep_1000 & "##0" & sep_deci & "00");
end if;
when no_currency_red_2 =>
if xl.format >= BIFF4 then
WriteFmtStr(xl, "#" & sep_1000 & "##0" & sep_deci & "00;" &
"-#" & sep_1000 & "##0" & sep_deci & "00");
end if;
when currency_0 =>
WriteFmtStr(xl, "$ #" & sep_1000 & "##0;$ -#" & sep_1000 & "##0");
when currency_red_0 =>
WriteFmtStr(xl, "$ #" & sep_1000 & "##0;$ -#" & sep_1000 & "##0");
-- [Red] doesn't go with non-English versions of Excel !!
when currency_2 =>
WriteFmtStr(xl, "$ #" & sep_1000 & "##0" & sep_deci & "00;" &
"$ -#" & sep_1000 & "##0" & sep_deci & "00");
when currency_red_2 =>
WriteFmtStr(xl, "$ #" & sep_1000 & "##0" & sep_deci & "00;" &
"$ -#" & sep_1000 & "##0" & sep_deci & "00");
when percent_0 => WriteFmtStr(xl, "0%"); -- 'Percent' built-in style
when percent_2 => WriteFmtStr(xl, "0" & sep_deci & "00%");
when scientific => WriteFmtStr(xl, "0" & sep_deci & "00E+00");
when fraction_1 =>
if xl.format >= BIFF3 then