text
stringlengths
0
234
font_for_styles, font_2, font_3 : Font_type;
--
function Encoding_code return Unsigned_16 is -- 5.17 CODEPAGE, p. 145
begin
case xl.encoding is
when Windows_CP_874 => return 874;
when Windows_CP_932 => return 932;
when Windows_CP_936 => return 936;
when Windows_CP_949 => return 949;
when Windows_CP_950 => return 950;
when Windows_CP_1250 => return 1250;
when Windows_CP_1251 => return 1251;
when Windows_CP_1252 =>
case xl.format is
when BIFF2 .. BIFF3 =>
return 16#8001#;
when BIFF4 =>
return 1252;
end case;
when Windows_CP_1253 => return 1253;
when Windows_CP_1254 => return 1254;
when Windows_CP_1255 => return 1255;
when Windows_CP_1256 => return 1256;
when Windows_CP_1257 => return 1257;
when Windows_CP_1258 => return 1258;
when Windows_CP_1361 => return 1361;
when Apple_Roman => return 10000;
end case;
end Encoding_code;
--
begin
Write_BOF(xl);
-- 5.17 CODEPAGE, p. 145
case xl.format is
-- when BIFF8 => -- UTF-16
-- WriteBiff(xl, 16#0042#, Intel_16(16#04B0#));
when others =>
WriteBiff(xl, 16#0042#, Intel_16(Encoding_code));
end case;
-- 5.14 CALCMODE
WriteBiff(xl, 16#000D#, Intel_16(1)); -- 1 => automatic
-- 5.85 REFMODE
WriteBiff(xl, 16#000F#, Intel_16(1)); -- 1 => A1 mode
-- 5.28 DATEMODE
WriteBiff(xl, 16#0022#, Intel_16(0)); -- 0 => 1900; 1 => 1904 Date system
-- NB: the 1904 variant (Mac) is ignored by LibreOffice (<= 3.5), then wrong dates !
--
Define_font(xl,"Arial", 10, xl.def_font);
Define_font(xl,"Arial", 10, font_for_styles); -- Used by BIFF3+'s styles
Define_font(xl,"Calibri", 10, font_2); -- Defined in BIFF3 files written by Excel 2002
Define_font(xl,"Calibri", 10, font_3); -- Defined in BIFF3 files written by Excel 2002
WriteFmtRecords(xl);
-- 5.111 WINDOWPROTECT
WriteBiff(xl, 16#0019#, Intel_16(0));
-- Define default format
Define_format(xl, xl.def_font, general, xl.def_fmt);
if xl.format >= BIFF3 then
-- Don't ask why we need the following useless formats, but it is as Excel 2002
-- write formats. Additionally, the default format is turned into decimal_2
-- when a file without those useless formats is opened in Excel (2002) !
Define_format(xl, font_for_styles, general, xl.def_fmt);
Define_format(xl, font_for_styles, general, xl.def_fmt);
Define_format(xl, font_2, general, xl.def_fmt);
Define_format(xl, font_2, general, xl.def_fmt);
for i in 5..15 loop
Define_format(xl, xl.def_font, general, xl.def_fmt);
end loop;
-- Final default format index is the last changed xl.def_fmt
end if;
Use_default_format(xl);
-- Define formats for the BIFF3+ "styles":
Define_format(xl, font_for_styles, decimal_2, xl.cma_fmt);
Define_format(xl, font_for_styles, currency_0, xl.ccy_fmt);
Define_format(xl, font_for_styles, percent_0, xl.pct_fmt);
-- Define styles - 5.103 STYLE p. 212
-- NB: - it is BIFF3+ (we cheat a bit if selected format is BIFF2).
-- - these "styles" seem to be a zombie feature of Excel 3
-- - the whole purpose of including this is because format
-- buttons (%)(,) in Excel 95 through 2007 are using these styles;
-- if the styles are not defined, those buttons are not working
-- when an Excel Writer sheet is open in MS Excel.
Define_style(xl.cma_fmt, Comma_Style);
Define_style(xl.ccy_fmt, Currency_Style);
Define_style(xl.pct_fmt, Percent_Style);
xl.dimrecpos:= Index(xl);
Write_Dimensions(xl);
xl.is_created:= True;
end Write_Worksheet_header;
type Font_or_Background is (for_font, for_background);
type Color_pair is array(Font_or_Background) of Unsigned_16;
auto_color: constant Color_pair:=
(16#7FFF#, -- system window text colour
16#0019# -- system window background colour
);
color_code: constant array(Excel_type, Color_type) of Color_pair :=
( BIFF2 =>
(
black => (0, 0),