Board index » delphi » Parsing tables in Word
Will
![]() Delphi Developer |
Parsing tables in Word2005-12-14 07:36:20 PM delphi232 I have a number of word documents with varying numbers of tables in them. I can load the document and pull the data out of the tavbles but I think I have a logic error in the code as the results are incorrect. Can anyone help? Test table has ten cells: 1 2 3 4 5 6 7 8 9 10 Output from my code looks like this: 6 1 6 6 6 6 1 6 6 6 Code: // adjust stringgrid columns StringGrid1.RowCount := iRows; StringGrid1.ColCount := iCols; // loop through cells for iGridRows := 0 to iRows - 1 do for jGridCols := 0 to iCols do begin CellText := Table.Cell(jGridCols, iGridRows).Range.FormattedText; if not VarisEmpty(CellText) then begin // Remove Tabs CellText := StringReplace(CellText, #$D, '', [rfReplaceAll]); // Remove linebreaks CellText := StringReplace(CellText, #$7, '', [rfReplaceAll]); // fill Stringgrid Stringgrid1.Cells[jGridCols, iGridRows] := CellText; end; end; |