Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Strings #25

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
357 changes: 199 additions & 158 deletions zexmlss/examples/createexml/createexml.dproj

Large diffs are not rendered by default.

Binary file modified zexmlss/examples/createexml/createexml.res
Binary file not shown.
86 changes: 40 additions & 46 deletions zexmlss/examples/createexml/unit_main.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//������ ������������� zexmlss
// ������ �������� � �������� ���������
//пример использования zexmlss
// создаёт документ с таблицей умножения
unit unit_main;

{$IFDEF FPC}
Expand All @@ -8,6 +8,8 @@

interface

{$I compver.inc}

uses
{$IFDEF FPC}
LCLIntf, LResources,
Expand Down Expand Up @@ -37,20 +39,20 @@ implementation
uses
{$IfDef Unicode} AnsiStrings, {$EndIf} TypInfo,
{$IFNDEF FPC}
{$IF CompilerVersion > 22}zeZippyXE2, {$ELSE} zeZippyAB,{� ���� ���� �����} {$IFEND} //<XE2 have not zip!
{$IF CompilerVersion > 22}zeZippyXE2, {$ELSE} zeZippyAB,{у кого чего стоит} {$IFEND} //<XE2 have not zip!
{$Else} zeZippyLaz,{$EndIf}
zeSave, zeSaveODS, zeSaveXLSX, zeSaveEXML, zexlsx, zeodfs;
{$IFNDEF FPC}
{$R *.dfm}
{$ENDIF}

//������� �������� �� ��������� ��������� � ������ (��� ������� - utf8)
//Функция перевода из локальной кодировки в нужную (для примера - в utf8)
function my_local_to_some_encoding(value: ansistring): ansistring;
begin
result := AnsiToUtf8(value);
end;

//������� ����
//Создать файл
procedure TfrmMain.CreateEXMLSS();
var
sd: TSaveDialog;
Expand All @@ -61,7 +63,6 @@ procedure TfrmMain.CreateEXMLSS();
ha: TZHorizontalAlignment;
s: string;
_ConvertParams: integer;

begin
TextConverter := nil;
{$IFNDEF FPC}
Expand All @@ -75,14 +76,15 @@ procedure TfrmMain.CreateEXMLSS();
sd.Options := sd.Options + [ofOverwritePrompt];
if sd.Execute then
begin

tz := TZEXMLSS.Create(nil);
try
//� ��������� 2 ��������
//В документе 2 страницы
tz.Sheets.Count := 2;
tz.Sheets[0].Title := '������� ��������';
//������� �����
tz.Sheets[0].Title := 'Таблица Пифагора';
//добавим стили
tz.Styles.Count := 7;
//0 - ��� ��������� (20)
//0 - для заголовка (20)
tz.Styles[0].Font.Size := 20;
tz.Styles[0].Font.Style := [fsBold];
tz.Styles[0].Font.Name := 'Tahoma';
Expand All @@ -91,65 +93,65 @@ procedure TfrmMain.CreateEXMLSS();
tz.Styles[0].Alignment.Horizontal := ZHCenter;
tz.Styles[0].Alignment.Vertical := ZVCenter;
tz.Styles[0].Alignment.WrapText := true;
//1 - ����� ��� �������
//1 - стиль для таблицы
tz.Styles[1].Border[0].Weight := 1;
tz.Styles[1].Border[0].LineStyle := ZEContinuous;
for i := 1 to 3 do tz.Styles[1].Border[i].Assign(tz.Styles[1].Border[0]);

//6 - ������ ������� � ����� �������
//6 - разные границы в одной таблице
tz.Styles[6].Assign(tz.Styles[1]);
for i := 0 to 3 do tz.Styles[6].Border[i].Weight := 2;

//2 - ����� ��� ��������� ������� (������ �� ������)
//2 - стиль для заголовка таблицы (жирный по центру)
tz.Styles[2].Assign(tz.Styles[1]);
tz.Styles[2].Font.Style := [fsBold];
tz.Styles[2].Alignment.Horizontal := ZHCenter;
//3-�� �����
//3-ий стиль
tz.Styles[3].Font.Size := 16;
tz.Styles[3].Font.Name := 'Arial Black';
//4-�� �����
//4-ый стиль
tz.Styles[4].Font.Size := 18;
tz.Styles[4].Font.Name := 'Arial';
//5-�� �����
//5-ый стиль
tz.Styles[5].Font.Size := 14;
tz.Styles[5].Font.Name := 'Arial Black';

with tz.Sheets[0] do
begin
//��������� ���������� ����� � ��������
//установим количество строк и столбцов
RowCount := 20 + Ord(High(TZVerticalAlignment )) + 2;
ColCount := 20;

Cell[0, 0].CellStyle := 3;
Cell[0, 0].Data := '������ ������������� zexmlss';
Cell[0, 0].Data := 'Пример использования zexmlss';

//������ � �������
//ячейка с ссылкой
Cell[0, 2].CellStyle := 4;
Cell[0, 2].Data := '�������� ��������: http://avemey.com';
Cell[0, 2].Data := 'Домашняя страница: http://avemey.com';
Cell[0, 2].Href := 'http://avemey.com';
Cell[0, 2].HRefScreenTip := '�������� �� ������'#13#10'(����� ����������� ��������� � ������)';
Cell[0, 2].HRefScreenTip := 'Клацните по ссылке'#13#10'(текст всплывающей подсказки к ссылке)';
MergeCells.AddRectXY(0, 2, 10, 2);

//����������
//Примечание
Cell[0, 3].CellStyle := 5;
Cell[0, 3].Data := '���� ����������!';
Cell[0, 3].Comment := '����� ���������� 1';
Cell[0, 3].CommentAuthor := '���-�� 1 ������� ����������';
Cell[0, 3].Data := 'Есть примечание!';
Cell[0, 3].Comment := 'Текст примечания 1';
Cell[0, 3].CommentAuthor := 'Кто-то 1 оставил примечание';
Cell[0, 3].ShowComment := true;

Cell[16, 3].CellStyle := 5;
Cell[16, 3].Data := '���� ����������!';
Cell[16, 3].Comment := '����� ���������� 2';
Cell[16, 3].CommentAuthor := '���-�� 2 ������� ����������';
Cell[16, 3].Data := 'Тоже примечание!';
Cell[16, 3].Comment := 'Текст примечания 2';
Cell[16, 3].CommentAuthor := 'Кто-то 2 оставил примечание';
Cell[16, 3].ShowComment := true;
Cell[16, 3].AlwaysShowComment := true;
ColWidths[16] := 160; //������ �������
ColWidths[16] := 160; //Ширина столбца

Cell[1, 1].CellStyle := 0;
Cell[1, 1].Data := '������� ��������� (������� ��������)';
Cell[1, 1].Data := 'Таблица умножения (таблица Пифагора)';
MergeCells.AddRectXY(1, 1, 16, 1);

Cell[0, 6].Data := '������������'#13#10'������!';
Cell[0, 6].AsString := 'Объединённая'#13#10'ячейка!';
Cell[0, 6].CellStyle := 0;
MergeCells.AddRectXY(0, 6, 3, 14);

Expand Down Expand Up @@ -235,13 +237,13 @@ procedure TfrmMain.CreateEXMLSS();
end;
end;

//�������� ������ � 0 �� 1-�� ��������
//копируем данные с 0 на 1-ую страницу
tz.Sheets[1].Assign(tz.Sheets[0]);
tz.Sheets[1].Title := '������� �������� (�������)';
tz.Sheets[1].Title := 'Таблица Пифагора (формулы)';

//�� ������ �������� ����� ������������ �������.
//���������� ������� ���� R1C1 (��� ����� ����� ����������� � ������)
s := '=R6C*RC6'; // ���������� � �������� �� 1 ������
//На второй странице будем использовать формулы.
//Используем формулы вида R1C1 (они проще всего переводятся в другие)
s := '=R6C*RC6'; // координаты в табличке на 1 больше

if (AnsiEndsText('.xml', sd.FileName)) then
with tz.Sheets[1] do
Expand All @@ -260,16 +262,8 @@ procedure TfrmMain.CreateEXMLSS();
Cell[5 + i, 5 + j].Formula := ZER1C1ToA1(s, 5 + i, 5 + j, _ConvertParams);
end;

//��������� 0-�� � 1-�� �������� � ����
//��������� - utf8, ��� ���������='utf-8' (��� utf-8 ����� ''), BOM=''
// SaveXmlssToEXML(tz, sd.FileName, [0, 1], [], @TextConverter, 'utf-8');

if AnsiEndsText('.xlsx', sd.FileName) then
SaveXmlssToXLSX(tz, sd.FileName, [0], [], @TextConverter, 'utf-8')
else if AnsiEndsText('.ods', sd.FileName) then
SaveXmlssToODFS(tz, sd.FileName, [0], [], @TextConverter, 'utf-8')
else
TZXMLSSave.From(tz).Charset('utf-8', TextConverter).Save(sd.FileName);
// Removed Old code
TZXMLSSave.From(tz).Charset('utf-8', TextConverter).Save(sd.FileName);
// Page 1 - formulae - only XML SS format

// formulae would fail in XLSX format and Excel would complain on "corrupt worksheet"
Expand Down
44 changes: 44 additions & 0 deletions zexmlss/packages/Delphi Berlin+/Berlin+ Group.groupproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{461C6C16-F74B-4634-80C5-EC7AC2F9D877}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Projects Include="zexmlsslib.dproj">
<Dependencies/>
</Projects>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality.12</Borland.Personality>
<Borland.ProjectType/>
<BorlandProject>
<Default.Personality/>
</BorlandProject>
</ProjectExtensions>
<Target Name="zexmlsslib">
<MSBuild Projects="zexmlsslib.dproj"/>
</Target>
<Target Name="zexmlsslib:Clean">
<MSBuild Projects="zexmlsslib.dproj" Targets="Clean"/>
</Target>
<Target Name="zexmlsslib:Make">
<MSBuild Projects="zexmlsslib.dproj" Targets="Make"/>
</Target>
<Target Name="Build">
<CallTarget Targets="zexmlsslib"/>
</Target>
<Target Name="Clean">
<CallTarget Targets="zexmlsslib:Clean"/>
</Target>
<Target Name="Make">
<CallTarget Targets="zexmlsslib:Make"/>
</Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
<ItemGroup Condition="'$(BuildGroup)'=='Build All'">
<BuildGroupProject Include="zexmlsslib.dproj">
<ProjectGuid>{3CC3B766-2D13-4B54-8E0D-A3D82AD28218}</ProjectGuid>
<Configurations>Debug;Release</Configurations>
<Platforms>Win32;Win64</Platforms>
<Enabled>True</Enabled>
</BuildGroupProject>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions zexmlss/packages/Delphi Berlin+/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Used to generate DCU files under lib folder
55 changes: 55 additions & 0 deletions zexmlss/packages/Delphi Berlin+/zexmlsslib.dpk
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package zexmlsslib;

{$R *.res}
{$R '..\..\src\zexmlss.dcr'}
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO OFF}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST ON}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$DEFINE NOZCOLORSTRINGGRID}
{$ENDIF IMPLICITBUILDING}
{$DESCRIPTION 'ZEXMLSS component'}
{$IMPLICITBUILD ON}

requires
vcl;

contains
zexmlss in '..\..\src\zexmlss.pas',
zsspxml in '..\..\src\zsspxml.pas',
zeodfs in '..\..\src\zeodfs.pas',
duansistr in '..\..\src\duansistr.pas',
zesavecommon in '..\..\src\zesavecommon.pas',
zeformula in '..\..\src\zeformula.pas',
zexmlssutils in '..\..\src\zexmlssutils.pas',
zearchhelper in '..\..\src\zearchhelper.pas',
zexlsx in '..\..\src\zexlsx.pas',
zeSave in '..\..\src\zeSave.pas',
zeSaveEXML in '..\..\src\zeSaveEXML.pas',
zeSaveODS in '..\..\src\zeSaveODS.pas',
zeSaveXLSX in '..\..\src\zeSaveXLSX.pas',
zeZippy in '..\..\src\zeZippy.pas',
zeZippyXE2 in '..\..\src\zeZippyXE2.pas',
zeZippyAB in '..\..\src\zeZippyAB.pas',
zenumberformats in '..\..\src\zenumberformats.pas';

end.
Loading