View previous topic :: View next topic
|
Author |
Message |
Chandan1993
New User
Joined: 21 May 2017 Posts: 6 Location: India
|
|
|
|
Hi All,
I have unloaded the record from table in to PS file and now i want write the record in excel format in PS file. is it possible ?
Reason why i am doing this i need to send email of unloaded file records and records should be written as tabular format in email.
Thanks You ! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
now i want write the record in excel format in PS file. is it possible ? |
Yes. The EASY way is to write the data as a comma-delimited data set, transfer to a server, and open the .csv with Excel. This does not allow any fonts or special formatting, however.
If your site has purchased SAS, SAS can read the data set and produce an Excel output for transfer to a server. This allows some special formatting to be done.
If your site has purchased a spreadsheet package for the mainframe that does generate Excel format, you could use that to process the data set and transfer the output to a server.
The other option is to read the Microsoft file specifications document for Excel (the last time I looked 4 years ago it was well over 1,000 pages) and write a program on the mainframe to generate the .xlsx or .xls directly. An accomplished team of 4 to 6 programmers could probably get this done within a year if they focus on it.
And, by the way, even if the data is transferred as Excel data the email may or may not be tabular; that would depend more upon your email client and how it formats data. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
What I do if I want to send formatted spreadsheets from a batch job(note I NEVER have access to commercial program designed for this) is use Excel as a painter for the layout and save it as xml. The trick is populating placeholder fields so you can better parse the xml.
Then it's just a matter of creating the program to either replace all of the placeholders if you used a static layout, or copy the data rows if the number of rows will change. Name it xls so that it will open in Excel.
The only downside is that with recent versions of Excel you get a warning that the file is not in the same format as the extension. But it opens in excel just fine.
Been doing this for years and it's never let me down. Started doing this in dbasevi when Excel first had the save as html, which also works fine. But saving as html doesn't work from the mainframe because Excels, html format includes characters which don't translate from ascii to ebcdic. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Quote: |
I have unloaded the record from table in to PS file
|
How complex it is to write comma or tab separated SELECT query ? I advise to use CONCAT or || in SELECT query it self the way you would like the data to be seen and delimited instead of post patch work |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
Quote: |
How complex it is to write comma or tab separated SELECT query ? I advise to use CONCAT or || in SELECT query it self the way you would like the data to be seen and delimited instead of post patch work |
For some cases it's not a matter of it being hard to create a CSV file but a matter of user friendliness. If your users need to then format it, it's less friendly. And sometimes you want even more than just a report. You might want other fancy 'Excel' stuff.
So, while CSV is the method I prefer most, there are cases where it's not sufficient and another option needs to be used. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Quote: |
For some cases it's not a matter of it being hard to create a CSV file but a matter of user friendliness. If your users need to then format it, it's less friendly. And sometimes you want even more than just a report. You might want other fancy 'Excel' stuff. |
One can still play around the raw data after its being given in CSV or excel format with. I am all saying is to get that raw data into file by comma or tab delimited in SELECT query itself, which is simpler to do. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Chandan1993 wrote: |
...send email of unloaded file records and records should be written as tabular format in email.... |
Option 1: send mail in HTML format with <table></table> tags.
Option 2: Use DIF (Data Interchange Format) instead of CSV.
DIF is not as friendly as CSV, some things won't stick (like column width or "Freeze Top Row") but it can contain formulas, which is already a big improvement ! |
|
Back to top |
|
|
phunsoft
New User
Joined: 19 Jul 2018 Posts: 11 Location: Switzerland
|
|
|
|
In a former job, we wrote a program to generate an XML-format Excel file directly. I don't have the code handy, but I seem to remember that this wasn't difficult at all. There is probably more programming effort to parse an XML and do variable subsituition. |
|
Back to top |
|
|
jasorn Warnings : 1 Active User
Joined: 12 Jul 2006 Posts: 191 Location: USA
|
|
|
|
phunsoft wrote: |
There is probably more programming effort to parse an XML and do variable subsituition. |
Perhaps, and it's not a bad idea regardless.
But I would think this becomes less true the more fancy the formatting becomes. The more fancy the formatting becomes the nicer it is to use excel as a painter. And often it's simply a matter of creating string replacements parameters. |
|
Back to top |
|
|
|