I have a client/server app that generates a document (invoice, order, etc) in a TComponent descendent object which is then written into a .dfm style file (using TStream.WriteComponent, and ObjectBinaryToText), and finally opened in MS Excel and interpreted there for printing in a template.
Sample of the output file:
This all works. The problem is that I had to write parsing routines in VBA for Excel to read the output file. This is really inefficient, as every property read must scan through every line before it. Some documents have many hundreds of lines, and it gets progressively slower and slower to read closer to the end of the file - on a modern machine some files take more than a minute to process.
Considering that XML is well known standard, I'd hoped I could use the XML capabilities of VBA to read my output if I could convert it to XML. And then, hopefully it would be a lot faster.
How do I do that?
Is there a better way I should be doing this? Perhaps I should create a proper excel worksheet in Delphi with unique identifiers and use Excel's VLOOKUP function?
Any thoughts?
Sample of the output file:
Code:
object TPurchase
Branch = '273'
TranNum = 'JX002'
DateRaised = 40736
DocumentName = 'Purchase Order'
DocLabel = 'ORIGINAL'
Details = <
item
OurStockCode = 'MISC'
Description = ' Ladies V Neck Vest'
OrderQty = 1
Cost = 21
end
item
OurStockCode = '/C'
Description = '(Black) Size 10'
OrderQty = 0
IgnoreOnInternal = False
end>
Comment = 'DRIVER TO PICK UP'
Revision = 0
end
This all works. The problem is that I had to write parsing routines in VBA for Excel to read the output file. This is really inefficient, as every property read must scan through every line before it. Some documents have many hundreds of lines, and it gets progressively slower and slower to read closer to the end of the file - on a modern machine some files take more than a minute to process.
Considering that XML is well known standard, I'd hoped I could use the XML capabilities of VBA to read my output if I could convert it to XML. And then, hopefully it would be a lot faster.
How do I do that?
Is there a better way I should be doing this? Perhaps I should create a proper excel worksheet in Delphi with unique identifiers and use Excel's VLOOKUP function?
Any thoughts?