4

I'm trying to reference data in an xlsx document in a text box (Insert --> Text) in ArcGIS.

Is it possible to make it so text in the text box is referenced directly from the xlsx document so it updates when the document is updated?

I'm looking into it, but, I'm having trouble finding this information online.

5

If the text in the excel spreadsheet is in a particular cell, you can identify this and insert this into a text box in ArcMap. You need to name the element in ArcMap so this can be referenced later on.

Please read the link for more information.

import xlrd 
import arcpy

wb = xlrd.open_workbook("YOUR_FILE.xls")  # xls file to read from
sh1 = wb.sheet_by_index(0) # first sheet in workbook

# rowx and colx (x for Excel) start at 1!
excelttext = sh1.cell(rowx=3,colx=2).value

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") #insert MXD
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "NAME_OF_ELEMENT"): # insert text element name
    elm.text = exceltext
arcpy.RefreshActiveView()
mxd.save()
2

In Layout View, Insert/Object, type = Excel (xls or xlsx), From File, Browse, Link option. The Link option supports refreshing data in the spreadsheet. You may have to save your map and reopen it to trigger a refresh.

External objects and ArcMap tables added to layouts will come in without a background or frame, so you may have to add a box background and play around with how this can be resized to accommodate changes in text size.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.