开发者

Is this possible in Excel: Open XLS via commandline, OnLoad import CSV data, Print as PDF, Close Doc?

开发者 https://www.devze.com 2023-01-30 15:31 出处:网络
Thinking that to solve a problem I\'ve got this is the fastest solution: Generate a custom CSV file on the file (this is already done via Perl).

Thinking that to solve a problem I've got this is the fastest solution:

  • Generate a custom CSV file on the file (this is already done via Perl).
  • Have a XLS document opened via commandline via a scripting language (clients already got a few Perl scripts running in this pipeline.)
  • Write VBA or record a macro that executes the following OnLoad:
    • Imports a the data from the CSV file into the report template,
    • Print the file via PDF driver to fixed location using data in the CSV to name the file.
    • Closes the XLS file.

So, is this possible via Excel macros, if not is it possible via VBA -- thanks!

NOTE: Appears I've got to have a copy of MS Office anyway, so this is much faster to get going than using Visual Studio Tools for Office (VSTO). The report template is 开发者_如何学JAVAgoing to be on a server, and this way the end user can build as many reports as they like, "test" by printing a PDF using a demo CSV file, and import/embed the marco or VBA when they're done. I'd looked in Jasper Reports, but the end user is putting ad-hoc static text and groupings all over the report and I figure this way they can build reports how ever they want and then automate them. Both of these questions by me and the resulting comments/feedback are related to this question:

  • In Excel, is it possible to automate reading of CSV data into a template and printing it to PDF from the commandline?
  • Is it possible to deploy a VB application made in Excel as a stand alone app?

FOCUS OF QUESTION: Again, focus of the question is if this is possible via Excel marcos, if not macros VBA, and if there's any huge issue with this approach; for example, I know this is going to be "slow" since Excel would be loaded per job, but there's 16GB of ram on the server and it's not used at all. Figure since I've got to have a copy of office on the server anyway, this is a much faster approach.

If you've got any questions, let me know via comments.


I suppose you could launch the report file from perl and then have a macro inside the report file automatically look for the newest csv file to import. Then you could process and output. So you just need to launch the proper excel file with the embedded macros from perl and then let excel and VBA take over.

0

精彩评论

暂无评论...
验证码 换一张
取 消