Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
AssignFile(outfile, SaveDialog1.FileName);
Rewrite(outfile);
writeln(outfile, '"', ListView1.Columns[0].Caption, '","',
ListView1.Columns[1].Caption, '","',
ListView1.Columns[2].Caption, '","',
ListView1.Columns[3].Caption, '","',
ListView1.Columns[4].Caption, '"');
for i := 0 to (ListView1.Items.Count - 1) do
begin
A := ListView1.Items[i];
writeln(outfile, '"', A.Caption, '","',
A.SubItems.Strings[0], '","',
A.SubItems.Strings[1], '","',
A.SubItems.Strings[2], '","',
A.SubItems.Strings[3], '"');
end;
CloseFile(outfile);
var
i: integer;
a: tlistitem;
outfile: textfile;
begin
if SaveDialog1.Execute then
begin
Screen.Cursor:= crHourGlass;
try
AssignFile(outfile, SaveDialog1.FileName);
Rewrite(outfile);
writeln(outfile, '"',
listview1.Columns[0].Caption, '","',
listview1.Columns[1].Caption, '","',
listview1.Columns[2].Caption, '","',
listview1.Columns[3].Caption, '"', #13#10);
for i := 0 to (listview1.Items.Count - 1) do
begin
A := listview1.Items[i];
writeln(outfile, '"',
A.Caption, '","',
A.SubItems.Strings[0], '","',
A.SubItems.Strings[1], '","',
A.SubItems.Strings[2], '","');
end;
CloseFile(outfile);
ShowMessage('Exported Table: ' + #13#10 + #13#10 + SaveDialog1.FileName);
except on exception do
ShowMessage('Could not save Table!');
end;
Screen.Cursor:= crDefault;
end;
procedure TForm1.AddListView(x, y: integer; ListItem: TListItem; instr: string);
var
NewColumn: TListColumn;
begin
if x = 0 then
begin
NewColumn := Listview1.Columns.Add;
NewColumn.Caption := instr;
end
else
begin
if y = 0 then
ListItem.Caption := instr
else
ListItem.Subitems.Add(instr);
end;
end;
procedure TForm1.split_string(x: integer; instr: string);
var
partstr: string;
reststr: string;
y: integer;
ListItem: TListItem;
begin
reststr := instr;
y := 0;
if x <> 0 then
ListItem := ListView1.Items.Add;
while Pos('",', reststr) <> 0 do
begin
partstr := Copy(reststr, 2, Pos('",', reststr)-2);
AddListView(x, y, ListItem, partstr);
inc(y);
reststr := Copy(reststr, Length(PartStr) + 4, Length(reststr));
end;
partstr := Copy(reststr, 2, Length(reststr) - 2);
AddListView(x, y, ListItem, partstr);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
infile: TextFile;
instr: string;
x: integer;
begin
if OpenDialog1.Execute then
begin
ListView1.ViewStyle := vsReport;
AssignFile(infile, OpenDialog1.Filename);
reset(infile);
x := 0;
while not eof(infile) do
begin
readln(infile, instr);
split_string(x, instr);
inc(x);
end;
closefile(infile);
MessageDlg('CSV file loaded.', mtInformation, [mbOK], 0);
end;
end;