Select to view content in your preferred language

Python script to generate xls report

1280
2
10-24-2013 01:29 AM
VictoriaWyeth
Deactivated User
Hello

I wonder if someone can help me please.
I am trying to write a python script which will generate a report in Excel but I need the "Use cell merging" function to be set to true for the final report. I have got the script to generate the report ok but I don't know how to implement to function for cell merging.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
                           r"C:\MyRLF.rlf",
                           r"C:\ProjectReport.xls",
                           "EXTENT",
                           extent=df.extent)
del mxd

Is someone able to help me please?
Tags (2)
0 Kudos
2 Replies
XanderBakker
Esri Esteemed Contributor
Hi,

Not sure what you exactly want:

  1. merge cells together so that for instance Cel A1 and B1 apear as a single cell?

  2. or combine data into 1 field.

Considering the first option, I really don't know. If this is not something you can define in your report layout file, then you would have to dig into the Excel model and program it.

In case you just want to concatenate data from 2 (or more) fields into 1 field, you can prepare the data itself (add a column and use the field calculator) or do this in your report layout file.

Merge data together in Report Layout

  • On the right side of the screen you will see "Fields" and below that "Calculated"

  • Right click on Calculated and choose "Add":

[ATTACH=CONFIG]28566[/ATTACH]


  • Your field will be named "Field1"

  • In the properties specify a formula like: myFieldName1 + " - " + myFieldName2

[ATTACH=CONFIG]28567[/ATTACH]


  • Reference your new (calculated) field "Field1" in your report designer

[ATTACH=CONFIG]28568[/ATTACH]

Hope this works for you.

Kind regards,

Xander
0 Kudos
VictoriaWyeth
Deactivated User
Thanks for your reply Xander.

Unfortunately it is the first option you mentioned which I require. However, your idea about programming it in Excel is a good one and that is the way I have done it by writing a small macro.

Thanks for your help.
0 Kudos