text
stringlengths
0
234
end if;
when BIFF3 | BIFF4 =>
if num in -2**29..2**29-1 then
Write_as_30_bit_signed(xl, r, c, Integer_32(num));
else
Write_as_double(xl, r, c, Long_Float(num));
end if;
end case;
end Write;
-- -- Function taken from Wasabee.Encoding.
-- function ISO_8859_1_to_UTF_16(s: String) return Wide_String is
-- -- This conversion is a trivial 8-bit to 16-bit copy.
-- r: Wide_String(s'Range);
-- begin
-- for i in s'Range loop
-- r(i):= Wide_Character'Val(Character'Pos(s(i)));
-- end loop;
-- return r;
-- end ISO_8859_1_to_UTF_16;
-- 5.63 LABEL
procedure Write (
xl : in out Excel_Out_Stream;
r,
c : Positive;
str : String)
is
begin
Jump_to_and_store_max(xl, r, c);
if str'Length > 0 then
case xl.format is
when BIFF2 =>
WriteBiff(xl, 16#0004#,
Intel_16(Unsigned_16(r-1)) &
Intel_16(Unsigned_16(c-1)) &
Cell_attributes(xl) &
To_buf_8_bit_length(str)
);
when BIFF3 | BIFF4 =>
WriteBiff(xl, 16#0204#,
Intel_16(Unsigned_16(r-1)) &
Intel_16(Unsigned_16(c-1)) &
Intel_16(Unsigned_16(xl.xf_in_use)) &
To_buf_16_bit_length(str)
);
-- when BIFF8 =>
-- WriteBiff(xl, 16#0204#,
-- Intel_16(Unsigned_16(r-1)) &
-- Intel_16(Unsigned_16(c-1)) &
-- Intel_16(Unsigned_16(xl.xf_in_use)) &
-- To_buf_16_bit_length(ISO_8859_1_to_UTF_16(str))
-- );
end case;
end if;
Jump_to(xl, r, c+1); -- Store and check new position
end Write;
procedure Write(xl: in out Excel_Out_Stream; r,c : Positive; str : Unbounded_String)
is
begin
Write(xl, r,c, To_String(str));
end Write;
-- Excel uses a floating-point type for time - ouch!
--
function To_Number(date: Time) return Long_Float is
-- 1901 is the lowest year supported by Ada.Calendar.
-- 1900 is not a leap year, but Lotus 1-2-3, then Excel, consider it
-- as a leap year. So, with 1901, we skip that issue anyway...
--
function Days_since_1901 (y, m, d : Integer) return Integer is
function Is_leap (y: Integer) return Boolean is
begin
if y mod 4 = 0 then
if y mod 100 = 0 then
if y mod 400 = 0 then
return True;
else
return False;
end if;
else
return True;
end if;
else
return False;
end if;
end Is_leap;
days_of_previous_months : Integer;
days_of_previous_years : Integer;
y_diff, y_diff_4, y_diff_100, y_diff_400 : Integer;
begin
case m is
when 02 => days_of_previous_months := 31;
when 03 => days_of_previous_months := 59;
when 04 => days_of_previous_months := 90;
when 05 => days_of_previous_months := 120;
when 06 => days_of_previous_months := 151;
when 07 => days_of_previous_months := 181;
when 08 => days_of_previous_months := 212;