text
stringlengths
0
234
column : Positive;
width : Natural)
is
begin
Write_column_width(xl, column, column, width);
end Write_column_width;
procedure Write_column_width(
xl : in out Excel_Out_Stream;
first_column,
last_column : Positive;
width : Natural
)
is
begin
case xl.format is
when BIFF2 =>
-- 5.20 COLWIDTH (BIFF2 only)
WriteBiff(xl, 16#0024#,
Unsigned_8(first_column-1) &
Unsigned_8(last_column-1) &
Intel_16(Unsigned_16(width * 256)));
when BIFF3 | BIFF4 =>
-- 5.18 COLINFO (BIFF3+)
WriteBiff(xl, 16#007D#,
Intel_16(Unsigned_16(first_column-1)) &
Intel_16(Unsigned_16(last_column-1)) &
Intel_16(Unsigned_16(width * 256)) &
Intel_16(0) & -- Index to XF record (5.115) for default column formatting
Intel_16(0) & -- Option flags
(0,0) -- Not used
);
for j in first_column .. last_column loop
xl.std_col_width(j):= False;
end loop;
end case;
end Write_column_width;
-- 5.88 ROW
-- The OpenOffice documentation tells nice stories about row blocks,
-- but single ROW commands can also be put before in the data stream,
-- where the column widths are set. Excel saves with blocks of ROW
-- commands, most of them useless.
procedure Write_row_height(
xl : Excel_Out_Stream;
row : Positive;
height : Natural
)
is
row_info_base: Byte_buffer:=
Intel_16(Unsigned_16(row - 1)) &
Intel_16(0) & -- col. min.
Intel_16(255) & -- col. max.
Intel_16(Unsigned_16(height * y_scale));
fDyZero: Unsigned_8:= 0;
begin
case xl.format is
when BIFF2 =>
WriteBiff(xl, 16#0008#,
row_info_base &
(1..3 => 0) &
Intel_16(0) -- offset to data
);
when BIFF3 | BIFF4 =>
if height = 0 then -- proper hiding (needed with LibreOffice)
fDyZero:= 1;
row_info_base(row_info_base'Last - 1 .. row_info_base'Last):=
Intel_16(16#8000#);
end if;
WriteBiff(xl, 16#0208#,
row_info_base &
-- http://msdn.microsoft.com/en-us/library/dd906757(v=office.12).aspx
(0, 0, -- reserved1 (2 bytes): MUST be zero, and MUST be ignored.
0, 0, -- unused1 (2 bytes): Undefined and MUST be ignored.
fDyZero * 32 + -- D - fDyZero (1 bit): row is hidden
1 * 64 + -- E - fUnsynced (1 bit): row height was manually set
0 * 128, -- F - fGhostDirty (1 bit): the row was formatted
1) & -- reserved3 (1 byte): MUST be 1, and MUST be ignored
Intel_16(15)
-- ^ ixfe_val, then 4 bits.
-- If fGhostDirty is 0, ixfe_val is undefined and MUST be ignored.
);
end case;
end Write_row_height;
-- 5.45 FONT, p.171
procedure Define_font(
xl : in out Excel_Out_Stream;
font_name : String;
height : Positive;
font : out Font_type;
style : Font_style:= regular;
color : Color_type:= automatic
)
is
style_bits, mask: Unsigned_16;
begin
style_bits:= 0;
mask:= 1;