Changeset 167 for trunk/Packages/Common/Table.pas
- Timestamp:
- Jul 1, 2023, 11:54:02 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Table.pas
r158 r167 39 39 procedure GetOutputListView(ListView: TListView); 40 40 function GetOutput(OutputFormat: TTableFormat): string; 41 procedure SetInputTabs(Text: string); 42 procedure SetInputPlain(Text: string); 43 procedure SetInputCsv(Text: string); 44 procedure SetInputXml(Text: string); 45 procedure SetInputHtml(Text: string); 46 procedure SetInputMediaWiki(Text: string); 47 procedure SetInput(OutputFormat: TTableFormat; Text: string); 41 48 constructor Create; 42 49 destructor Destroy; override; … … 55 62 Common; 56 63 64 resourcestring 65 SUnsupportedFormat = 'Unsupported format'; 66 57 67 { TTable } 58 68 … … 74 84 procedure TTable.Clear; 75 85 begin 86 Columns.Clear; 76 87 Rows.Clear; 77 88 end; … … 138 149 begin 139 150 Result := '<?xml version="1.0" encoding="UTF-8"?>' + LineEnding + 140 '< vcard>' + LineEnding +151 '<table>' + LineEnding + 141 152 ' <title>' + Title + '</title>' + LineEnding + 142 ' < contacts>' + LineEnding;153 ' <rows>' + LineEnding; 143 154 for I := 0 to Rows.Count - 1 do begin 144 Result := Result + ' < contact>' + LineEnding;155 Result := Result + ' <row>' + LineEnding; 145 156 for J := 0 to Rows[I].Cells.Count - 1 do 146 157 if Rows[I].Cells[J] <> '' then 147 Result := Result + ' < property name="' + Columns[J] + '">' + ReplaceXmlEntities(Rows[I].Cells[J]) + '</property>' + LineEnding;148 Result := Result + ' </ contact>' + LineEnding;149 end; 150 Result := Result + ' </ contacts>' + LineEnding +151 '</ vcard>';158 Result := Result + ' <cell name="' + Columns[J] + '">' + ReplaceXmlEntities(Rows[I].Cells[J]) + '</cell>' + LineEnding; 159 Result := Result + ' </row>' + LineEnding; 160 end; 161 Result := Result + ' </rows>' + LineEnding + 162 '</table>'; 152 163 end; 153 164 … … 255 266 tfMediaWiki: Result := GetOutputMediaWiki; 256 267 tfXml: Result := GetOutputXml; 257 else Result := ''; 268 else raise Exception.Create(SUnsupportedFormat); 269 end; 270 end; 271 272 procedure TTable.SetInputTabs(Text: string); 273 begin 274 275 end; 276 277 procedure TTable.SetInputPlain(Text: string); 278 begin 279 280 end; 281 282 procedure TTable.SetInputCsv(Text: string); 283 begin 284 285 end; 286 287 procedure TTable.SetInputXml(Text: string); 288 begin 289 290 end; 291 292 procedure TTable.SetInputHtml(Text: string); 293 begin 294 295 end; 296 297 procedure TTable.SetInputMediaWiki(Text: string); 298 begin 299 300 end; 301 302 procedure TTable.SetInput(OutputFormat: TTableFormat; Text: string); 303 begin 304 case OutputFormat of 305 tfExcel: SetInputTabs(Text); 306 tfPlain: SetInputPlain(Text); 307 tfCsv: SetInputCsv(Text); 308 tfHtml: SetInputHtml(Text); 309 tfMediaWiki: SetInputMediaWiki(Text); 310 tfXml: SetInputXml(Text); 311 else raise Exception.Create(SUnsupportedFormat); 258 312 end; 259 313 end;
Note:
See TracChangeset
for help on using the changeset viewer.