Export output to Excel with NO formatting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Export output to Excel with NO formatting

Mark Webb-5
I'm exporting [Version 18.1] regression coefs to Excel.
The following formatting is transferred from SPSS to Excel -
Bold
Wrapped text
Merged cells
Boarders
Row heights

For my purposes I have to undo these format settings.

Can I set up output in SPSS so that it is unformatted ?
I have tried different "views" with no success.
There used to be a text view if I'm not mistaken.

Thanking you.
Mark Webb

Line +27 (21) 786 4379
Cell +27 (72) 199 1000
Fax to email +27 (86) 5513075
Skype  webbmark
Email  [hidden email]

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Export output to Excel with NO formatting

Albert-Jan Roskam
hi,

I recently read about the approach below. You need the xlwt module to write to xls.
The OMS identifiers in Spss can be used to tweak the output. The program writes only the beta coefficients.

import spss, spssaux, xlwt
spssaux.OpenDataFile(r"C:\Program Files\SPSSInc\PASWStatistics17\Samples\English\employee data.sav")
cmd = "REGRESSION /DEPENDENT salary / METHOD=ENTER educ jobcat."
analysis, output, outputcat = "Regression", "Coefficients", "Beta"
tag, errorlevel = spssaux.createXmlOutput(cmd, omsid=analysis, subtype=output)
values = spssaux.getValuesFromXmlWorkspace(tag, output, colCategory=outputcat, cellAttrib="number")
wb = xlwt.Workbook()
ws = wb.add_sheet(output)
row, col = 0, 0
ws.write(row, col, outputcat)
for row, value in enumerate(values):
    ws.write(row+1, col, value)
wb.save("d:/temp/%s.xls" % output)

Cheers!!
Albert-Jan

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the face of ambiguity, refuse the temptation to guess.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- On Fri, 2/5/10, Mark Webb <[hidden email]> wrote:

From: Mark Webb <[hidden email]>
Subject: [SPSSX-L] Export output to Excel with NO formatting
To: [hidden email]
Date: Friday, February 5, 2010, 6:39 AM

I'm exporting [Version 18.1] regression coefs to Excel.
The following formatting is transferred from SPSS to Excel -
Bold
Wrapped text
Merged cells
Boarders
Row heights

For my purposes I have to undo these format settings.

Can I set up output in SPSS so that it is unformatted ?
I have tried different "views" with no success.
There used to be a text view if I'm not mistaken.

Thanking you.
Mark Webb

Line +27 (21) 786 4379
Cell +27 (72) 199 1000
Fax to email +27 (86) 5513075
Skype  webbmark
Email  targetlinkmark@...

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@... (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD