by
ru
en
by

Avemey

logo
FilesMainLinksPhotosAnime

Under Translation...

ZEXMLSS


zexmlss can create and load excel 2002/2003 XML (SpreadsheetML / XML Spreadsheet), OpenDocument Format (ODS), Office Open XML (xlsx) files without installed MS Excell or OpenOffice calc.
Works in Lazarus (tested with Lazarus 1.0.4 and FPC 2.6 under Linux and Windows XP), in Delphi 7, Borland Developer Studio 2005, BDS 2006, CodeGear Delphi 2007, CodeGear RAD Studio 2009 and 2010, Delphi XE and Delphi XE2, in C++ Builder 6.
License: zlib License
Last version: 0.0.6 2013.02.23 (beta).

Document created by zexmlss, opened in excel 2003
Document created by zexmlss, opened in excel 2003
zexmlss + ZColorStringGrid
zexmlss + ZColorStringGrid
Document created by zexmlss, opened in OpenOffice.org 3.0.1
Document created by zexmlss, opened in OpenOffice.org 3.0.1


zip zexmlss_0_0_6_bin.zip (4330Kb) - Source code + compiled samples.
zip zexmlss_0_0_6_src.zip (730Kb) - Source code.

Key features:
  • Read and write excel XML files in windows-1251, CP866, UTF-8, UTF-16 (Little Endian and Big Endian) encodings
  • Save and Load Open Document Format (ODS) as directory (Lazarus/Delphi) and as packed single file (Lazarus (for delphi if read readme.en))
  • Import and export Office Open XML (xlsx) from directory (Lazarus/Delphi) and from packed single file (Lazarus (reame.en -> Delphi))
  • Simple copy cells to/from StringGrid
  • Simple copy cells (with style and merged cells) to/from ZColorStringGrid (only for Delphi and C++Builder if not defined NOZCOLORSTRINGGRID in zexml.inc)
::: Code samples ::: History ::: Delphi+zexmlss+zip :::

Main classes:

Functions:

Function
Short description
function GridToXmlSS(var XMLSS: TZEXMLSS; const PageNum: integer; var Grid: TStringGrid; ToCol: integer; ToRow: integer; BCol, BRow, ECol, ERow: integer; ignorebgcolor: boolean; _border: byte): boolean; overload; Copy data from Grid to XMLSS page. XMLSS - Storage. PageNum - page number. Grid - the stringgrid needed to copy data to XMLSS. ToCol - column number for insertion. ToRow - row number for insertion. BCol - grid's left top cell's column. BRow - grid's left top cell's row. ECol - grid's right bottom cell's column. ERow - grid's right bottom cell's row. ignorebgcolor - if true, then ignore cell's background color. _border - specifies how to copy cell's borders (1 - cells with borders, 0 - cells without borders).
Return True if copied successful.
function GridToXmlSS(var XMLSS: TZEXMLSS; const PageNum: integer; var Grid: TZColorStringGrid; ToCol: integer; ToRow: integer; BCol, BRow, ECol, ERow: integer; ignorebgcolor: boolean; _border: byte): boolean; overload; Copy data from Grid to XMLSS page. XMLSS - Storage. PageNum - page number. Grid - thr zcolorstringgrid, with needed to copy data to XMLSS. ToCol - column number for insertion. ToRow - row number for insertion. BCol - grid's left top cell's column. BRow - grid's left top cell's row. ECol - grid's right bottom cell's column. ERow - grid's right bottom cell's row. ignorebgcolor - if true, then ignore cell's background color. _border - specifies how to copy cell's borders (1 - cells with borders, 0 - cells without borders, 2 - cells with borders, except style sgNone).
For Delphi and CBuilder only!
Return True if copied successful.
function XmlSSToGrid(var Grid: TStringGrid; var XMLSS: TZEXMLSS; const PageNum: integer; ToCol: integer; ToRow: integer; BCol, BRow, ECol, ERow: integer; InsertMode: byte; StyleCopy: integer = 511): boolean; overload; Copy data from TZEXMLSS to TStringGrid. Grid - stringgrid to insert cells into. XMLSS - storage. PageNum - page number. ToCol - column number for insertion. ToRow - row number for insertion. BCol - XMLSS's left top cell's column. BRow - XMLSS's left top cell's row. ECol - XMLSS's right bottom cell's column. ERow - XMLSS's right bottom cell's row. InsertMode - specifies how to insert or add cells to the stringgrid (0 - cells not shifted; 1 - cells shifted to the right in the stringgrid; 2 - cells shifted to the down in the stringgrid; 3 - cells shifted to the right and down in the stringgrid). StyleCopy - specifies how copy style (0 - do not copy style, if StyleCopy and 16 = 16 - copy cell's size).
Return True if copied successful.
function XmlSSToGrid(var Grid: TZColorStringGrid; var XMLSS: TZEXMLSS; const PageNum: integer; ToCol: integer; ToRow: integer; BCol, BRow, ECol, ERow: integer; InsertMode: byte; StyleCopy: integer = 1023): boolean; overload; Copy data from TZEXMLSS page to TZColorStringGrid. Grid - grid to insert cells into. XMLSS - storage. PageNum - page number. ToCol - column number for insertion. ToRow - row number for insertion. BCol - XMLSS's left top cell's column. BRow - XMLSS's left top cell's row. ECol - XMLSS's right bottom cell's column. ERow - XMLSS's right bottom cell's row. InsertMode - specifies how to insert or add cells to the stringgrid (0 - cells not shifted; 1 - cells shifted to the right in the stringgrid; 2 - cells shifted to the down in the stringgrid; 3 - cells shifted to the right and down in the stringgrid). StyleCopy - specifies how copy style:
  • 0 - do not copy style
  • StyleCopy and 1 = 1 - copy BGColor
  • StyleCopy and 2 = 2 - copy Vertical Alignment
  • StyleCopy and 4 = 4 - copy Horizontal Alignment
  • StyleCopy and 8 = 8 - copy Font
  • StyleCopy and 16 = 16 - copy cell's size
  • StyleCopy and 32 = 32 - copy WordWrap
  • StyleCopy and 64 = 64 - copy Merge Area
  • StyleCopy and 128 = 128 - delete merged cells in place of insert before insertion
  • StyleCopy and 256 = 256 - set Borderstyle to sqNone in place of insert
  • StyleCopy and 512 = 512 - if cell's text do not fit in cell then cell's height will resize
  • StyleCopy and 1024 = 1024 - if cell's text do not fit in cell then cell's width will resize
  • StyleCopy and 2048 = 2048 - set default style of XMLSS to added cells on shift-place instead of the default style of the grid
For Delphi and CBuilder only!
Return True if copied successful.
function SaveXmlssToEXML(var XMLSS: TZEXMLSS; Stream: TStream; const SheetsNumbers:array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Save to the Stream in Excel XML SpreadSheet format. XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal to elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding (for example, AnsiToUtf8 - convert to UTF-8 encoding). CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
function SaveXmlssToEXML(var XMLSS: TZEXMLSS; FileName: string; const SheetsNumbers: array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Save to the file FileName in Excel XML SpreadSheet format. XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding (for example, AnsiToUtf8 - convert to UTF-8 encoding). CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
function SaveXmlssToODFSPath(var XMLSS: TZEXMLSS; PathName: string; const SheetsNumbers: array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Save to the directory PathName in non packed Open Document Format (ODS). XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding (for example, AnsiToUtf8 - convert to UTF-8 encoding). CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
The path PathName must exist!
function SaveXmlssToODFS(var XMLSS: TZEXMLSS; FileName: string; const SheetsNumbers: array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Warning: for Lazarus only!
Save to the file FileName in Open Documen Format (ODS). XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding (for example, AnsiToUtf8 - convert to UTF-8 encoding). CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
function SaveXmlssToXLSXPath(var XMLSS: TZEXMLSS; PathName: string; const SheetsNumbers: array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Save to the directory PathName in non packed Office Open XML (xlsx). XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding. CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
The path PathName must exist!
function SaveXmlssToXLSX(var XMLSS: TZEXMLSS; FileName: string; const SheetsNumbers: array of integer; const SheetsNames: array of string; TextConverter: TAnsiToCPConverter; CodePageName: string; BOM: ansistring = ''): integer; overload; Warning: for Lazarus only!
Save to the file FileName in xlsx. XMLSS - storage. SheetsNumbers - array with needed numbers of sheets (if array is empty then all sheets will be saved). SheetsNames - array with titles of sheets (elements count in SheetsName must be equal elements count in SheetsNumbers). TextConverter - text converter from local encoding to needed encoding. CodePageName - name of codepage. BOM - Byte Order Mark.
Return 0 if saved successful.
function ReadEXMLSS(var XMLSS: TZEXMLSS; Stream: TStream): integer; overload; Read Excel XML SpreadSheet from Stream to XMLSS.
Return 0 if read successful.
function ReadEXMLSS(var XMLSS: TZEXMLSS; FileName: string): integer; overload; Read Excel XML SpreadSheet from file FileName to XMLSS.
Return 0 if read successful.
function ReadODFSPath(var XMLSS: TZEXMLSS; DirName: string): integer; Read unpacked ODS from path DirName to XMLSS.
Return 0 if read successful.
function ReadODFS(var XMLSS: TZEXMLSS; FileName: string); Warning: for Lazarus only!
Read ODS from file FileName to XMLSS.
Return 0 if read successful.
function ReadXLSXPath(var XMLSS: TZEXMLSS; DirName: string): integer; Read unpacked xlsx from path DirName to XMLSS.
Return 0 if read successful.
function ReadXLSX(var XMLSS: TZEXMLSS; FileName: string): integer; Warning: for Lazarus only!
Read xlsx from file FileName to XMLSS.
Return 0 if read successful.

TZEXMLSS

Inherited from TComponent. Is a container for the contents of a spreadsheet.

Properties:
Property
Short description
Sheets: TZSheets; Document sheets.
Styles: TZStyles; Styles.
DefaultSheetOptions: TZSheetOptions; Default sheet options.
DocumentProperties: TZEXMLDocumentProperties; Document properties.

TZSheets

Inherited from TPersistent. Contains sheets of the document.

Properties:
Property
Short description
Count: integer; Number of sheets in the document.
Sheet[num: integer]: TZSheet; document's sheet num.

TZSheet

Inherited from TPersistent. Contains a sheet of the document.

Properties:
Property
Short description
Cell[ACol, ARow: integer]: TZCell; Cell at the intersection of column ACol and row ARow.
ColCount: integer; Specifies the number of columns in the sheet.
Columns[num: integer]: TZColOptions; Options of column num.
ColWidths[num: integer]: real; Get or set the width (in points) of column num in the sheet.
DefaultColWidth: real; Default column width.
DefaultRowHeight: real; Default row height.
MergeCells: TZMergeCells; Merged cells.
Protect: boolean; Indicates whether or not this sheet is protected.
False by default.
RightToLeft: boolean; If True, the window displays from right to left else window displays from left to right.
False by default.
RowCount: integer; Specifies the number of rows in the sheet.
RowHeights[num: integer]: real; Get or set the height (in points) of row num in the sheet.
Rows[num: integer]: TZRowOptions; Specifies various properties of the Row num.
Selected: boolean; Indicates whether or not this sheet is selecteded.
SheetOptions: TZSheetOptions; Specifies various properties of the sheet.
Title: string; Sheet title.

TZCell

Inherited from TPersistent. It's a cell of spreadsheet.

Properties:
Property
Short description
AlwaysShowComment: boolean; Always show comment.
False by default.
CellStyle: integer; Cell style number.
-1 by default.
CellType: TZCellType; Cell type.
ZEansistring (string) by default.
Comment: string; Comment text.
CommentAuthor: string; Author of comment.
Data: string; Specifies the value of this cell to show on screen.
Formula: string; Formula in R1C1 style.
Href: string; Specifies the URL to link this cell.
HRefScreenTip: string; Displays the caption of URL to show on screen.
ShowComment: boolean; Show comment.
False by default.

TZSheetOptions

Inherited from TPersistent. Sheet options.

Properties:
Property
Short description
ActiveCol: word; Column number with active cell.
0 by default.
ActiveRow: word; Row number with active cell.
0 by default.
CenterHorizontal: boolean; If True, the document should be centered horizontally on the page.
False by default.
CenterVertical: boolean; If True, the document should be centered vertically on the page.
False by default.
FooterMargin: word; The size of footer in millimeters.
13 mm by default.
HeaderMargin: word; The size of header in millimeters.
13 mm by default.
FooterData: string; Specifies the data for the footer.
HeaderData: string; Specifies the data for the header.
MarginBottom: word; Specifies the bottom margin on the page in millimeters.
25 mm by default.
MarginLeft: word; Specifies the left margin on the page in millimeters.
20 mm by default.
MarginTop: word; Specifies the top margin on the page in millimeters.
25 mm by default.
MarginRight: word; Specifies the right margin on the page in millimeters.
20 mm by default.
PaperSize: byte; Paper Size (Paper size table).
9 (A4) by default.
PortraitOrientation: boolean; Specifies the orientation of the page (True - Portrait, False - Landscape).
True by default.
StartPageNumber: integer; Specifies the starting page number for print.
1 by default.

TZRowColOptions

Inherited from TPersistent. Common options for columns and rows. Ancestor for TZColOptions and TZRowOptions.

Properties:
Property
Short description
Hidden: boolean; True specifies that column or row is hidden.
False (not hidden) by default.
StyleID: integer; Specifies a style for column or row.
-1 by default.
Breaked: boolean; Page break after column or row.
False (no break) by default.

TZRowOptions

Inherited from TZRowColOptions. Row options.

Properties:
Property
Short description
AutoFitHeight: boolean; If True, it means that this row should be autosized.
Height: real; Row height in points (1 point = 1/72" = 0.3528 mm).
HeightMM: real; Row height in mm.
HeightPix: real; Row height in pixels.

TZColOptions

Inherited from TZRowColOptions. Column options.

Properties:
Property
Short description
AutoFitWidth: boolean; If True, it means that this column should be autosized.
Width: real; Column width in points.
WidthMM: real; Column width in mm.
WidthPix: real; Column width in pixels.

TZMergeCells

Inherited from TPersistent. Merged Cells.
Properties:
Property
Short description
Count: integer; Count of merged cells in the sheet.
Read Only!
Items[Num: Integer]: TRect; Returns the coordinates of the merged cell of Num. (Left, Top) - the left top cell, (Right, Bottom) - the right bottom cell.
Num - number of merged cell.
Read Only!

Methods:
TZMergeCells methods
Short description
function AddRect(Rct: TRect): byte; Adds a merged cell enclosed into rectangle Rct.
Return:
  0 - The merged cell was successfully added
  1 - Specified merged cell is outside the boundary of sheet
  2 - Specified merged cell overlaps (included) in the previously entered areas
  3 - Area of one cell does not add
  4 - Attempt to merge fixed and not fixed cells
function AddRectXY(x1, y1, x2, y2: integer): byte; Adds a merged cell enclosed into rectangle (x1, y1, x2, y2). (x1, y1) - left top cell, (x2, y2) - right bottom cell.
Return is similar to AddRect(Rct: TRect).
procedure Clear(); Removes all merged cells.
function DeleteItem(num: integer): boolean; Delete merged cell num.
Return True if the cell is successfully deleted.
function InLeftTopCorner(ACol, ARow: integer): integer; Returns the number of merged cell, in which the cell [ACol, ARow] is top left. If returns a negative value - there is no such area.
function InMergeRange(ACol, ARow: integer): integer; Returns the number of merged cell that includes cell [ACol, ARow]. If returns a negative value - cell [ACol, ARow] is not contained in the Merged area.

TZStyles

Inherited from TPersistent. Contains styles of the document.

Properties:
Property
Short description
Count: integer; Count styles in the document.
Items[num: integer]: TZStyle; Style num (-1 - DefaultStyle).
DefaultStyle: TZStyle; Default style ( = Items[-1]).

Methods:
TZStyles methods
Short description
function Add(const Style: TZStyle; CheckMatch: boolean = false): integer; Add a Style.
Style - style, CheckMatch - checks the coincidence of this style with introduced in earlier styles.
Return number of added (or, if CheckMatch = True, previously introduced) style.
procedure Clear(); Delete all styles.
function DeleteStyle(num: integer): integer; Delete style num, styles with a larger number are shifting. num - style number.
Return:
    0 - if successfully deleted
   -1 - can not delete style
function Find(const Style: TZStyle): integer; Find number to match the Style introduced in earlier styles.
Return:
   -2 - if style not found
   -1 - if style = DefaultStyle
    0..Count-1 - Style number

TZStyle

Inherited from TPersistent. Cell style.

Properties:
Property
Short description
Alignment: TZAlignment; Specifies how text is aligned within the cell.
BGColor: TColor; Background color of the cell.
clWindow by default.
Border: TZBorder; Cell borders.
CellPattern: TZCellPattern; Fill pattern of the cell.
ZPNone by default.
Font: TFont; Cell font.
HideFormula: boolean; Indicates whether or not this cell's formula should be hidden when sheet protection is enabled.
False by default.
NumberFormat: string; Defines the number format that should be in cells referencing this style.
PatternColor: TColor; Color of fill pattern.
clWindow by default.
Protect: boolean; Indicates whether or not this cell is protected.
True by default.

Method:
function IsEqual(Source: TPersistent): boolean; - Return True when style equal Source.

TZAlignment

Inherited from TPersistent. Specifies how text is aligned within the cell.

Properties:
Property
Short description
Horizontal: TZHorizontalAlignment; Specifies how text is aligned by horizontally within the cell.
ZHAutomatic by default.
Indent: integer; Specifies how far the cell's text is indented.
0 by default.
Rotate: integer; Specifies the rotation of the text within the cell (from -90 to 90).
0 by default.
ShrinkToFit: boolean; If True then the text size will shrunk so to all of the text fits within the cell.
False by default.
Vertical: TZVerticalAlignment; Specifies how text is aligned by vertically within the cell.
ZVAutomatic by default.
VerticalText: boolean; If True each letter is drawn horizontally, one above the other.
False by default.
WrapText: boolean; Specifies whether the text in cell should wrap at the cell boundary.
False by default.

Method:
function IsEqual(Source: TPersistent): boolean; - Return True when all properties equal to Source's properties.

TZBorder

Inherited from TPersistent. Borders of cell.

Properties:
Property
Short description
Border[Num: integer]: TZBorderStyle; Set border where num:
  • 0 - Left border
  • 1 - Top border
  • 2 - Right border
  • 3 - Bottom border
  • 4 - DiagonalLeft (diagonal from upper left to lower right)
  • 5 - DiagonalRight (diagonal from lower left to upper right)
Left: TZBorderStyle; Left border.
Top: TZBorderStyle; Top border.
Right: TZBorderStyle; Right border.
Bottom: TZBorderStyle; Bottom border.
DiagonalLeft: TZBorderStyle; Diagonal from upper left to lower right.
DiagonalRight: TZBorderStyle; Diagonal from lower left to upper right.

Method:
function IsEqual(Source: TPersistent): boolean; - Return True when borders equal Source.

TZBorderStyle

Inherited from TPersistent. Border's style.

Properties:
Property
Short description
LineStyle: TZBorderType; Line style.
ZENone by default.
Weight: byte; Specifies the thickness of this border (0-3).
0 by default.
Color: TColor; Specifies the color of this border.
ClBlack by default.

Method:
function IsEqual(Source: TPersistent): boolean; - Return True, when border equal to Source.

TZEXMLDocumentProperties

Inherited from TPersistent. Document properties.

Properties:
Property
Short description
Author: string; Author of the document.
LastAuthor: string; Author of last changes in the document.
Created: TdateTime; Date and time of document creation.
Company: string; Company name.
ModeR1C1: boolean; Enabled R1C1 style in Excel.
False by default.

TZsspXMLWriter

Inherited from TPersistent. Class-writer can write xml to string, stream or file in Windows-1251, UTF-8, UTF-16 (BE and LE) encodings. Use TextConverter property for write in other encodings.

Properties:
Property
Short description
Attributes: TZAttributes; Tag's attributes.
AttributeQuote: ansichar; Quotation mark for attribute values ( '  (prime) or  "  (double prime)).
" (double prime) by default.
Buffer: ansistring; Buffer. (read only)
InProcess: boolean; Return True if writing in process. (read only)
MaxBufferLength: integer; Buffer length (>0). If InProcess = True then property read only.
4096 bytes by default.
NewLine: boolean; If True then tag starts with new line. If InProcess = True then property read only.
True by default.
TabLength: integer; Number of tab-symbols before tag. If InProcess = True then property read only.
0 by default.
TabSymbol: ansichar; Tab symbol (#32 (space) or #9 (tab)). If InProcess = True then property read only.
#32 by default.
TagCount: integer; Number of open tags before current tag. (read only)
Tags[num: integer]: ansistring; Return open tag number num. (read only)
TextConverter: TAnsiToCPConverter; Set text converter. If InProcess = True then property read only.
UnixNLSeparator: boolean; If True then newline character is #10 (LF) else newline "character" is #13#10 (CR+LF).

Methods:
TZsspXMLWriter methods
Short description
function BeginSaveToStream(Stream: TStream): boolean; Begin writing to Stream.
Return:
 True - start writing to stream. Sets InProcess True.
 False - could not write.
function BeginSaveToFile(FileName: ansistring): boolean; begin writing to file FileName.
Return:
 True - start writing to file. Sets InProcess True.
 False - could not write.
function BeginSaveToString(): boolean; Begin writing to string Buffer.
Return:
 True - start writing to Buffer. Sets InProcess True.
 False - could not write.
procedure EndSaveTo(); End writing to string/file/stream. Sets InProcess False.
procedure FlushBuffer(); Empties the Buffer. All characters from Buffer have been written to a file.
procedure WriteCDATA(CDATA: ansistring; CorrectCDATA: boolean; StartNewLine: boolean = true); overload; Write CDATA. CDATA - text. CorrectCDATA - if true then replaces ']]>' on ']]>'. StartNewLine - if true then starts from new line (ignored when NewLine = false).
procedure WriteCDATA(CDATA: ansistring); overload; Write CDATA. CDATA - text (CorrectCDATA = true; StartNewLine = true).
procedure WriteComment(Comment: ansistring; StartNewLine: boolean = true); Write comment. Comment - text of comment. StartNewLine - if true then start from new line (ignored when NewLine = false).
procedure WriteEmptyTag(TagName: ansistring; SAttributes: TZAttributes; StartNewLine: boolean; CheckEntity: boolean = true); overload; Write empty tag. TagName - name of tag. SAttributes - attributes. StartNewLine - if true then start from new line (ignored when NewLine = false). CheckEntity - if true then corrects entity.
procedure WriteEmptyTag(TagName: ansistring; StartNewLine: boolean; CheckEntity: boolean = true); overload; Write empty tag. TagName - name of tag. StartNewLine - if true then start from new line (ignored when NewLine = false). CheckEntity - if true then corrects entity. Attributes get from Attributes.
procedure WriteEmptyTag(TagName: ansistring); overload; Write empty tag. TagName - name of tag. (StartNewLine = True; CheckEntity = True) Attributes get from Attributes.
procedure WriteEndTagNode(); Write end of node.
procedure WriteInstruction(InstructionName: ansistring; SAttributes: TZAttributes; StartNewLine: boolean; CheckEntity: boolean = true); overload; Write instruction (<?instructionname ...?>). InstructionName - name of instruction. SAttributes - attributes. StartNewLine - if true then start from new line (ignored when NewLine = false). CheckEntity - if true then corrects entity.
procedure WriteInstruction(InstructionName: ansistring; StartNewLine: boolean; CheckEntity: boolean = true); overload; Write instruction (<?instructionname ...?>). InstructionName - name of instruction. StartNewLine - if true then start from new line (ignored when NewLine = false). CheckEntity - if true then corrects entity. Attributes get from Attributes.
procedure WriteInstruction(InstructionName: ansistring); overload; Write instruction (<?instructionname ...?>). InstructionName - name of instruction. (StartNewLine = True; CheckEntity = True) Attributes get from Attributes.
procedure WriteRaw(Text: ansistring; UseConverter: boolean; StartNewLine: boolean = true); Write not processed text. Text - text, UseConverter - used TextConverter, StartNewLine - if true then start from new line (ignored when NewLine = false).
WARNING: can break XML!
procedure WriteTag(TagName: ansistring; Text: ansistring; SAttributes: TZAttributes; StartNewLine: boolean; CloseTagNewLine: boolean; CheckEntity: boolean = true); overload; Write tag (<tag ...>text</tag>). TagName - name of tag. SAttributes - attributes. StartNewLine - if true then start from new line (ignored when NewLine = false). CloseTagNewLine - if true then closed tag starts from new line. CheckEntity - if true then corrects entity.
procedure WriteTag(TagName: ansistring; Text: ansistring; StartNewLine: boolean; CloseTagNewLine: boolean; CheckEntity: boolean = true); overload; Write tag. TagName - name of tag. StartNewLine - if true then start from new line (ignored when NewLine = false). CloseTagNewLine - if true then closed tag starts from new line. CheckEntity - if true then corrects entity. Attributes get from Attributes.
procedure WriteTag(TagName: ansistring); overload; Write tag. TagName - name of tag. Attributes get from Attributes. (StartNewLine = True; CloseTagNewLine = False; CheckEntity = True)
procedure WriteTagNode(TagName: ansistring; SAttributes: TZAttributes; StartNewLine: boolean; CloseTagNewLine: boolean; CheckEntity: boolean = true); overload; Write node. TagName - name of tag. SAttributes - attributes. StartNewLine - if true then start from new line (ignored when NewLine = false). CloseTagNewLine - if true then closed tag starts from new line. CheckEntity - if true then corrects entity.
procedure WriteTagNode(TagName: ansistring; StartNewLine: boolean; CloseTagNewLine: boolean; CheckEntity: boolean = true); overload; Write node. TagName - name of tag. StartNewLine - if true then start from new line (ignored when NewLine = false). CloseTagNewLine - if true then closed tag starts from new line. CheckEntity - if true then corrects entity. Attributes get from Attributes.
procedure WriteTagNode(TagName: ansistring); overload; Write node. TagName - name of tag. Attributes get from Attributes. (StartNewLine = True; CloseTagNewLine = False; CheckEntity = True)

TZsspXMLReader

Inherited from TPersistent. Class-reader. Read XML from string, stream or file in CP866, Windows-1251, UTF-8 and UTF-16 (BE and LE) encodings.

Properties:
Property
Short description
Attributes: TZAttributes; Attributes of tag.
ErrorCode: integer; Return error code. 0 - OK, 1 - value without quotes, etc. (RO)
IgnoreCase: boolean; If True then ignore case sensitive. If InProcess = True then property read only.
False by default.
InProcess: boolean; Return True when processed XML. (RO)
MaxBufferLength: integer; Buffer size (>=512). If InProcess = True then property read only.
4096 bytes by default.
RawTextTag: ansistring; Raw text. (RO)
TagCount: integer; Number of opened tags before current tag. (RO)
Tags[num: integer]: ansistring; Return opened tag number num. (RO)
TagName: ansistring; Return name of readed tag/instruction/comment. (RO)
TagValue: ansistring; Return CDATA or comment text. (RO)
TagType: byte; Return type of tag:
  • 0 - unknown
  • 1 - <?...?>
  • 2 - <![CDATA[..]]>
  • 3 - <!--..-->
  • 4 - <...>
  • 5 - <.../>
  • 6 - </...>

Methods:
TZsspXMLReader methods
Short description
function BeginReadFile(FileName: ansistring): integer; Begin to read XML from a file FileName.
Return:
  • 0 - OK
  • 1 - already in reading
  • 2 - error
  • 3 - Stream = nil
function BeginReadStream(Stream: TStream): integer; Begin to read XML from Stream.
Return 0 if no errors.
function BeginReadString(Source: ansistring; IgnoreCodePage: boolean = true): integer; Begin to read XML from string Source. Ignores encoding when IgnoreCodePage = True.
Return 0 if no errors.
function ReadTag(): boolean; Read tag.
procedure EndRead(); End reading.
Eof(): boolean; Return True when current file (stream or string) position is the end.

TZAttributes

Inherited from TPersistent. Builder attributes for tags.

Properties:
Property
Short description
Count: integer; Number of attributes. (RO)
Items[num: integer]: TZAttrArray; Access to the attribute-value by number num.
ItemsByName[Att: ansistring]: ansistring; Access to the attribute value by name Att.
ItemsByNum[num: integer]: ansistring; Access to the attribute value by number num.

Methods:
TZAttributes methods
Short description
procedure Add(AttrName: ansistring; Value: ansistring; TestMatch: boolean = true); overload; Adds attribute with AttrName name and value Value. If TestMatch = true then checks for attribute AttrName entry, if attribute was entered then changes it's value, else new attribute is added.
procedure Add(Attr: TZAttrArray; TestMatch: boolean = true); overload; Adds atribute Attr.
procedure Clear(); Delete all atributes.
procedure DeleteItem(Index: integer); Delete attribute with number Index. Attributes with larger number are shifting left.
procedure Insert(Index: integer; AttrName: ansistring; Value: ansistring; TestMatch: boolean = true); overload; Adds attribute AttrName with value Value on position Index.
procedure Insert(Index: integer; Attr: TZAttrArray; TestMatch: boolean = true); overload; Adds attribute Attr on position Index.
function ToString(quote: ansichar; CheckEntity: boolean; addempty: boolean): ansistring; overload; Return string with attributes. quote - quotation mark for attribute. CheckEntity - if true then corrects entity. If addempty = true then do not add attributes with empty value.
function ToString(CheckEntity: boolean): ansistring; overload; Return string with attributes. CheckEntity - if true then corrects entity. (quote = "; addempty = true)
function ToString(): ansistring; overload; Return string with attributes. (quote = "; CheckEntity = true; addempty = true)

Types:


Data type of cell
TZCellType = (ZENumber, ZEDateTime, ZEBoolean, ZEansistring, ZEError);

Style lines of the cell border
TZBorderType = (ZENone, ZEContinuous, ZEDot, ZEDash, ZEDashDot, ZEDashDotDot,ZESlantDashDot, ZEDouble);

Horizontal alignment
TZHorizontalAlignment = (ZHAutomatic, ZHLeft, ZHCenter, ZHRight, ZHFill, ZHJustify, ZHCenterAcrossSelection, ZHDistributed, ZHJustifyDistributed);

Vertical alignment
TZVerticalAlignment = (ZVAutomatic, ZVTop, ZVBottom, ZVCenter, ZVJustify, ZVDistributed, ZVJustifyDistributed);

Fill pattern of the cell
TZCellPattern = (ZPNone, ZPSolid, ZPGray75, ZPGray50, ZPGray25, ZPGray125, ZPGray0625, ZPHorzStripe, ZPVertStripe, ZPReverseDiagStripe, ZPDiagStripe, ZPDiagCross, ZPThickDiagCross, ZPThinHorzStripe, ZPThinVertStripe, ZPThinReverseDiagStripe, ZPThinDiagStripe, ZPThinHorzCross, ZPThinDiagCross);

Text converter from local encoding to needed encoding
TAnsiToCPConverter = function (AnsiText: ansistring): ansistring;

Text converter from reading encoding to local encoding
TCPToAnsiConverter = TAnsiToCPConverter;

Attribute-value
TZAttrArray = array [0..1] of ansistring;

For compatibility with unicode Delphi (> = RAD Studio 2009) added:
  • TZAttrArrayH
  • TZAttributesH
  • TZsspXMLWriterH
  • TZsspXMLReaderH
For Free Pascal-a and Delphi < 2009 they are equal of types without postfix "H", for unicode Delphi these types fields ansistring replaced with string.

FilesMainLinksPhotosAnime

Copyright © 2006-2012 Ruslan V. Neborak