Hướng dẫn cho người dùng Hủy

Data merge using the Variables panel

  1. Illustrator User Guide
  2. Get to know Illustrator
    1. Introduction to Illustrator
      1. What's new in Illustrator
      2. Common questions
      3. Illustrator system requirements
      4. Illustrator for Apple silicon
    2. Workspace
      1. Workspace basics
      2. Create documents
      3. Learn faster with the Illustrator Discover panel
      4. Accelerate workflows using the Contextual Task Bar
      5. Toolbar
      6. Default keyboard shortcuts
      7. Customize keyboard shortcuts
      8. Introduction to artboards
      9. Manage artboards
      10. Customize the workspace
      11. Properties panel
      12. Set preferences
      13. Touch Workspace
      14. Microsoft Surface Dial support in Illustrator
      15. Undo edits and manage design history
      16. Rotate view
      17. Rulers, grids, and guides
      18. Accessibility in Illustrator
      19. Safe Mode
      20. View artwork
      21. Use the Touch Bar with Illustrator
      22. Files and templates
    3. Tools in Illustrator
      1. Tools at a glance
      2. Select tools
        1. Selection
        2. Direct Selection
        3. Group Selection
        4. Magic Wand
        5. Lasso
        6. Artboard
      3. Navigate tools
        1. Hand
        2. Rotate View
        3. Zoom
      4. Paint tools
        1. Gradient
        2. Mesh
        3. Shape Builder
      5. Text tools
        1. Type
        2. Type on a Path
        3. Vertical Type
      6. Draw tools
        1. Pen
        2. Add Anchor Point
        3. Delete Anchor Point
        4. Anchor Point
        5. Curvature
        6. Line Segment
        7. Rectangle
        8. Rounded Rectangle
        9. Ellipse
        10. Polygon
        11. Star
        12. Paintbrush
        13. Blob Brush
        14. Pencil
        15. Shaper
        16. Slice
      7. Modify tools
        1. Rotate
        2. Reflect
        3. Scale
        4. Shear
        5. Width
        6. Free Transform
        7. Eyedropper
        8. Blend
        9. Eraser
        10. Scissors
        11. Dimension
    4. Generative AI (not available in mainland China)
      1. Generate scenes, subjects, and icons using text prompts
      2. Generate vector patterns using text prompts
      3. Generate vector shape fills using text prompts
      4. Recolor your artwork using text prompts
    5. Quick actions
      1. Retro text
      2. Neon glow text
      3. Old school text
      4. Recolor
      5. Convert sketch to vector
  3. Illustrator on the web (beta)
    1. Illustrator on the web (beta) overview
    2. Illustrator on the web (beta) FAQ
    3. Troubleshooting issues FAQ
    4. Keyboard shortcuts for Illustrator on the web (beta)
    5. Create and combine shapes on the web
    6. Add and edit text on the web
    7. Apply colors and gradients on the web
    8. Draw and edit paths on the web
    9. Work with cloud documents on the web
    10. Invite collaborators to edit on the web
  4. Illustrator on the iPad
    1. Introduction to Illustrator on the iPad
      1. Illustrator on the iPad overview
      2. Illustrator on the iPad FAQs
      3. System requirements | Illustrator on the iPad
      4. What you can or cannot do on Illustrator on the iPad
    2. Workspace
      1. Illustrator on the iPad workspace
      2. Touch shortcuts and gestures
      3. Keyboard shortcuts for Illustrator on the iPad
      4. Manage your app settings
    3. Documents
      1. Work with documents in Illustrator on the iPad
      2. Import Photoshop and Fresco documents
    4. Select and arrange objects
      1. Create repeat objects
      2. Blend objects
    5. Drawing
      1. Draw and edit paths
      2. Draw and edit shapes
    6. Type
      1. Work with type and fonts
      2. Create text designs along a path
      3. Add your own fonts
    7. Work with images
      1. Vectorize raster images
    8. Color
      1. Apply colors and gradients
  5. Cloud documents
    1. Basics
      1. Work with Illustrator cloud documents
      2. Share and collaborate on Illustrator cloud documents
      3. Share documents for review
      4. Upgrade cloud storage for Adobe Illustrator
      5. Illustrator cloud documents | Common questions
    2. Troubleshooting
      1. Troubleshoot create or save issues for Illustrator cloud documents
      2. Troubleshoot Illustrator cloud documents issues
  6. Add and edit content
    1. Drawing
      1. Drawing basics
      2. Edit paths
      3. Draw pixel-perfect art
      4. Draw with the Pen, Curvature, or Pencil tool
      5. Draw simple lines and shapes
      6. Draw rectangular and polar grids
      7. Draw and edit flares
      8. Trace images
      9. Simplify a path
      10. Symbolism tools and symbol sets
      11. Adjust path segments
      12. Design a flower in 5 easy steps
      13. Create and edit a perspective grid
      14. Draw and modify objects on a perspective grid
      15. Use objects as symbols for repeat use
      16. Draw pixel-aligned paths for web workflows
    2. Measurement
      1. Measure and plot dimensions
    3. 3D objects and materials
      1. About 3D effects in Illustrator
      2. Create 3D graphics
      3. Map artwork over 3D objects
      4. Create 3D Text
      5. Create 3D objects
    4. Color
      1. About color
      2. Select colors
      3. Use and create swatches
      4. Adjust colors
      5. Use the Adobe Color Themes panel
      6. Color groups (harmonies)
      7. Color Themes panel
      8. Recolor your artwork
    5. Painting
      1. About painting
      2. Paint with fills and strokes
      3. Live Paint groups
      4. Gradients
      5. Brushes
      6. Transparency and blending modes
      7. Apply stroke on an object
      8. Create and edit patterns
      9. Meshes
      10. Patterns
    6. Select and arrange objects
      1. Select objects
      2. Layers
      3. Group and expand objects
      4. Move, align, and distribute objects
      5. Align, arrange, and move objects on a path
      6. Snap objects to glyph
      7. Snap objects to Japanese glyph
      8. Stack objects    
      9. Lock, hide, and delete objects
      10. Copy and duplicate objects
      11. Rotate and reflect objects
      12. Intertwine objects
      13. Create realistic art mockups
    7. Reshape objects
      1. Crop images
      2. Transform objects
      3. Combine objects
      4. Cut, divide, and trim objects
      5. Puppet Warp
      6. Scale, shear, and distort objects
      7. Blend objects
      8. Reshape using envelopes
      9. Reshape objects with effects
      10. Build new shapes with Shaper and Shape Builder tools
      11. Work with Live Corners
      12. Enhanced reshape workflows with touch support
      13. Edit clipping masks
      14. Live shapes
      15. Create shapes using the Shape Builder tool
      16. Global editing
    8. Type
      1. Add text and work with type objects
      2. Reflow Viewer
      3. Create bulleted and numbered lists
      4. Manage text area
      5. Fonts and typography
      6. Convert text within images into editable text
      7. Add basic formatting to text
      8. Add advanced formatting to text
      9. Import and export text
      10. Format paragraphs
      11. Special characters
      12. Create type on a path
      13. Character and paragraph styles
      14. Tabs
      15. Find missing fonts (Typekit workflow)
      16. Arabic and Hebrew type
      17. Fonts | FAQ and troubleshooting tips
      18. Creative typography designs
      19. Scale and rotate type
      20. Line and character spacing
      21. Hyphenation and line breaks
      22. Spelling and language dictionaries
      23. Format Asian characters
      24. Composers for Asian scripts
      25. Create text designs with blend objects
      26. Create a text poster using Image Trace
    9. Create special effects
      1. Work with effects
      2. Graphic styles
      3. Appearance attributes
      4. Create sketches and mosaics
      5. Drop shadows, glows, and feathering
      6. Summary of effects
    10. Web graphics
      1. Best practices for creating web graphics
      2. Graphs
      3. SVG
      4. Slices and image maps
  7. Import, export, and save
    1. Import
      1. Place multiple files
      2. Manage linked and embedded files
      3. Links information
      4. Unembed images
      5. Import artwork from Photoshop
      6. Import bitmap images
      7. Import Adobe PDF files
      8. Import EPS, DCS, and AutoCAD files
    2. Creative Cloud Libraries in Illustrator 
      1. Creative Cloud Libraries in Illustrator
    3. Save and export
      1. Save artwork
      2. Export artwork
      3. Create Adobe PDF files
      4. Adobe PDF options
      5. Use Illustrator artwork in Photoshop
      6. Collect assets and export in batches
      7. Package files
      8. Extract CSS | Illustrator CC
      9. Document info panel
  8. Printing
    1. Prepare for printing
      1. Set up documents for printing
      2. Change the page size and orientation
      3. Specify crop marks for trimming or aligning
      4. Get started with large canvas
    2. Printing
      1. Overprint
      2. Print with color management
      3. PostScript printing
      4. Print presets
      5. Printer's marks and bleeds
      6. Print and save transparent artwork
      7. Trapping
      8. Print color separations
      9. Print gradients, meshes, and color blends
      10. White Overprint
  9. Automate tasks
    1. Data merge using the Variables panel
    2. Automation with scripts
    3. Automation with actions
  10. Troubleshooting 
    1. Fixed issues
    2. Known issues
    3. Crash issues
    4. Recover files after crash
    5. File issues
    6. Supported file formats
    7. GPU device driver issues
    8. Wacom device issues
    9. DLL file issues
    10. Memory issues
    11. Preferences file issues
    12. Font issues
    13. Printer issues
    14. Share crash report with Adobe
    15. Improve Illustrator performance

Merge an Illustrator document with a data source file (CSV or XML file) with the Variables panel to create multiple variations of your artwork. You can change the names of participants on event badges or vary images across web banners and postcards without having to redo your artwork. Create one design and then quickly produce variations by importing the names or the images from a data source file.

Create custom variations of your design template for different projects, such as printable posters, web banners, and event badges, using the Variables panel.

Before you proceed

All you need for data merge is a data source file and a target document. 

  • The data source file contains information that varies in each version of the target document, such as the names, photographs, and addresses of the recipients of a form letter. A data source file can be a comma-delimited file (.csv) or an extensible markup language file (.xml). 
  • The target document is an Illustrator document that contains the base artwork to use as the template. This document can contain the data-field placeholder and the items that remain the same in each version of the merged document.

Access the data merge functionality

Data merge is accessible from the Variables panel in Illustrator (Window > Variables). The type and name of each variable in the document are listed in the panel. If the variable is bound to an object, then the Objects column displays the name of the bound object as it appears in the Layers panel. You can sort the rows by clicking items in the header bar: by variable name, object name, or by variable type.

Variables panel

A. Data set B. Panel menu C. Switch between data sets D. Name of bound object E. Variable name F. Variable type G. Lock variables H. Make object dynamic I. Make visibility dynamic J. Unbind variables K. Create variables L. Delete variables 

Quick steps for merging data

  1. Create an Illustrator document to use as the template.

  2. Set up your source data file in CSV or XML format. For more information, see Prepare a data source file.

  3. Import a data source file in Illustrator using the Variables panel. For more information, see Import a data source file.

  4. Bind a variable to an object in your template. For more information, see Bind variables to objects.

  5. Preview the document with each data set before you export all the files. For more information, see Preview the document with each data set.

  6. Export a batch of files from the data using the Actions panel in Illustrator. For more information, see Export files using the Actions panel.

Prepare a data source file

Data source files should be saved in a comma-delimited (.csv) or Extensible Markup Language (.xml) format.

Set up your CSV source files

In a comma-delimited (.csv) file, records are separated by paragraph breaks; fields are separated by commas or tabs. The data source file can also include text or paths that see images on disk. Before importing a CSV file, do the following to let Illustrator identify the variable type.

  1. Open your spreadsheet.

  2. Specify your data field name in the first row of your spreadsheet. Then, do the following:

    • At the beginning of the data field name, type an “at” symbol (@) to insert text or paths that refer to image files. The @ symbol is required only in the first line; subsequent lines should include the image paths.
    • Similarly, at the beginning of the data field name, type a “percentage” symbol (%) for graphs and a "hashtag" symbol (#) for visibility.
    • To define the visibility of an object, specify true or false for each data field.
    Lưu ý:
    • The data field names in your spreadsheet should not contain blank spaces. For example, you can specify the data field as Company_Name instead of Company Name
    • Similarly, the paths referring to image and graph files should not contain any blank spaces. For example, the path of an image file should be C:\Photos\BillTucker instead of C:\Photos\Bill Tucker.
    • All graph files linked from your data source file should be saved as comma-delimited (.csv) files.
    • If you get an error message when you type the @ symbol at the beginning of the field, type an apostrophe (') before the @ symbol (such as '@Photos) to validate the function. Some applications, such as Microsoft Excel, reserve the @ symbol for functions.

    (Windows) Example of image and graph references in the data source file

    Name

    Age

    @Photos

    %Graphs

    #Visibility

    Bill Tucker

    36

    C:\Photos\BillTucker.jpg

    C:\Photos\BillTucker.csv

    True

    Dat Nguyen

    53

    C:\MyDocuments\dat.jpg

    C:\MyDocuments\dat.csv

    True

    Maria Ruiz

    26

    C:\Photos\Ruiz.jpg

    C:\Photos\Ruiz.csv

    False

    (macOS) Example of image and graph references in the data source file

    Name

    Age

    @Photos

    %Graphs

    #Visibility

    Bill Tucker

    36

    /Users/photos/BillTucker.jpg

    /Users/photos/BillTucker.csv

    True

    Dat Nguyen

    53

    /Users/family/photos/dat.jpg

    /Users/family/photos/dat.csv

    True

    Maria Ruiz

    26

    /Users/alpha/photos/Ruiz.jpg

    /Users/alpha/photos/Ruiz.csv

    False

  3. Enter your data into the spreadsheet.

  4. Do one of the following:

    • Save spreadsheets created using the latest version of Microsoft Excel (2016 release) to the following file formats:
      • CSV (Comma delimited) (*.csv)
      • CSV (MS-DOS) (*.csv)
    • Save spreadsheets created using Apple Numbers to CSV format with Unicode (UTF-8) encoding.
    Lưu ý:

    Currently, CSV files exported in the formats mentioned above are supported in Illustrator. Other CSV file formats such as Macintosh Comma Separated (.csv) are not supported for data merge.

Prepare an XML file

  1. Define a variable in your document. For details, see Bind variables to objects.

  2. Select the Capture Data Set  button in the Variables panel.

  3. After you create the desired number of data sets, select Save Variable Library from the Variables panel menu to save the data sets as an XML file. Specify the filename and location, and select Save.

    Export the variables you've created in Illustrator as an XML file

  4. Now, edit the XML file in a text editing application such as Notepad++ (Windows) or TextWrangler (macOS) to include your data sets in this file.

    Example: editing an XML file using any text editing application

    A. Replace the path of the image B. Replace the string of text  

  5. Select Load Variable Library from the Variables panel menu to import your XML file in Illustrator. Select the XML file and select Open.

    Import variables into Illustrator

Import a data source file

To bind variables to the desired data, import a data source in the Variables panel. You can have only one data source file selected per document.

  1. Choose Window > Variables.

  2. In the Variables panel, select Import.

  3. In the Load Variable Library dialog box, select a data source file in CSV or XML format and select Open.

  4. You can edit, rename, or delete the data set later by choosing it from the Data Set drop‑down menu and editing its options.

    • Select a data set from the Data Set list in the Variables panel to switch between data sets. You can also select the Previous Data Set  button or the Next Data Set  button.
    • To apply the data on the artboard to the current data set, choose Update Data Set  from the Variables panel menu.
    • To rename a data set, edit the text directly in the Data Set text box. You can double-click the words Data Set (to the left of the Data Set text box), enter a new name, and select OK.
    • To delete a data set, select the Delete icon. You can also select Delete Data Set from the Variables panel menu.
    Lưu ý:

    The CSV (UTF-8 Comma Delimited) files containing double-byte characters created through Excel cannot be imported in the Variables panel. If you open the same file in text format and then save as CSV with UTF-8 encoding, the file is imported correctly.

Bind variables to objects

Use variables to define the elements in a template that you want to change. You can define four types of variables: Visibility variable, Text String variable, Linked File variable, and Graph Data variable. A variable’s type indicates which object attributes are changeable (dynamic). The type and name of each variable in the document are listed in the panel. If the variable is bound to an object, then the Objects column displays the name of the bound object as it appears in the Layers panel.

Type of variable

Icon to indicate a variable’s type

Definition

Visibility variables

Show or hide artwork.

Text String variables

Replace a string of text.

Linked File variables

Replace the object in the artboard with an object from another file.

Graph Data variables

Replace the values in a graph.

No Type (unbound) variable

Not bound to any object.

Follow these steps to define variables in Illustrator:

  1. Select an object.

  2. In the Variables panel (Window > Variables), select the variable you want to bind it with.

  3.  Select the Make Object Dynamic  button to bind the object with the variable.

Follow these steps to create a variable without binding it to an object:

  1. Select the New Variable  button in the Variables panel.

  2. To bind an object to the variable, select the object and the variable, and select the Make Visibility Dynamic  button or the Make Object Dynamic  button.

Lưu ý:

Variable names do not support Surrogate Pair and 4-byte characters. If you use these characters in a variable name, an error message is displayed.

Work with variables

You can edit a variable’s name or type, unbind a variable, and lock a variable using the Variables panel.

Unbinding a variable breaks the link between the variable and its object. Locking variables prevents you from creating variables, deleting variables, and editing variable options. However, you can bind and unbind objects to locked variables.

Change the name and type of a variable

  1. Select the variable in the Variables panel, and select Variable Options from the panel menu.

Unbind a variable

  1. Select the Unbind Variable  button in the Variables panel.

Lock or unlock all variables in a document

  1. Select the Lock Variables  button or Unlock Variablesbutton in the Variables panel.

Delete variables

Delete a variable to remove it from the Variables panel. If you delete a variable bound to an object, the object becomes static (unless the object is also bound to a variable of a different type).

  1. Select a variable you want to delete.

  2. Follow any of these options:

    • Select the Delete Variable  button in the Variables panel.

    • To delete the variable without confirmation, drag it to the Delete Variable  button.

Edit dynamic objects

You can change the data associated with a variable by editing the object to which it's bound. For example, if you’re working with a Visibility variable, you change the object’s visibility state in the Layers panel. Editing dynamic objects let you create multiple data sets in the template.

  1. Select a dynamic object on the artboard, or do one of the following to automatically select a dynamic object:

    • Alt‑click (Windows) or Option‑click (macOS) a variable in the Variables panel.

    • Select a variable in the Variables panel, and select Select Bound Object from the Variables panel menu.

    • Select All Bound Objects from the Variables panel menu to select all dynamic objects.

  2. Edit the data associated with the object as follows:

    • Edit the text string on the artboard.

    • Replace the image with the Links panel or the File > Place command for linked files.

    • Edit the data for graphs in the Graph Data dialog.

    • For all objects with dynamic visibility, change the state of visibility for the object in the Layers panel.

Identifying dynamic objects usingXML IDs

The Variables panel displays the names of dynamic objects as they appear in the Layers panel. If you save the template in SVG format for use with other Adobe products, these object names must conform to XML naming conventions. For example, XML names must begin with a letter, underscore, or colon, and cannot contain spaces.

Illustrator automatically assigns a valid XML ID to every dynamic object you create. To view, edit, and export object names using XML IDs, choose Edit > Preferences > Units (Windows) or Illustrator > Preferences > Units (Mac OS), and select XML ID.

Preview the document with each data set

To see how your final graphics will look, you can preview before you export all the files. Use the arrow keys next to Data Set in the Variables panel to navigate and preview the desired data set in your document.

Export files using the Actions panel

After you define variables and one or more data sets, you can output, in batch mode, artwork using the data set values. Do the following:

  1. Using the Actions panel (Window > Actions), record an action to save your document in the desired format. For details, see Automation with actions.

  2. Choose Batch from the Actions panel menu and select the action you’ve created in the previous step.

  3. For Source, select Data Sets to play the action on each dataset in the current file.

  4. For Destination, specify what you want to do with the processed files. You can leave the files open without saving the changes (None), save and close the file in their current location (Save And Close), or save the files to a different location (Folder).

    Depending on the Destination option, you can set additional options for saving the files. For more information, view Play an action on a batch of files.

  5. Select OK.

Save a template for data merge

When you define variables in an Illustrator document, you are creating a template for data merge. You can save the template in SVG format for use with other Adobe products, such as Adobe® Graphics Server. For example, a developer working with Adobe Graphics Server can bind the variables in the SVG file directly to a database or another data source.

  1. Choose File > Save As, enter a filename, select SVG as the file format, and click Save.

  2. Click More Options, and select Include Adobe Graphics Server Data. This option includes all information needed for variable substitution in the SVG file.

  3. Click OK.

Facing issues while importing your CSV file?

If you’re receiving the error: The incoming variable library is invalid while uploading a CSV data source file, check for the following:

  • Your CSV file is not blank.
  • The spreadsheets that you've created using the latest version of Microsoft Excel are saved as CSV (Comma delimited) (*.csv) or CSV (MS-DOS) (*.csv) and those created using Apple Numbers are saved as CSV format with Unicode (UTF-8) encoding. Data source files saved in any other file format such as Macintosh Comma Separated (*.csv) are not supported for data merge.
  • All columns have a data field name. For example, Illustrator displays the error message when a column in your data source file contains data but doesn't have a data field name.
  • The data source file doesn't have a blank column in between any filled columns. For example, Illustrator displays the error message when column B and D in your data source file contain data but column C is empty.
Example: errors while setting up a CSV source file for data merge

A. Data field name is missing for a column B. There's a blank column between filled columns 

  • The data field names in your spreadsheet don't contain any blank spaces.
  • The paths referring to image and graph files in your source file don't contain any blank spaces.
  • The graph files linked from your data source file are saved as comma-delimited (.csv) files.

related resources

Talk to us

We would love to hear from you. Share your thoughts with the Adobe Illustrator Community

 Adobe

Nhận trợ giúp nhanh chóng và dễ dàng hơn

Bạn là người dùng mới?

Adobe MAX 2024

Adobe MAX
Hội thảo sáng tạo

14–16/10 Bãi biển Miami và trực tuyến

Adobe MAX

Hội thảo sáng tạo

14–16/10 Bãi biển Miami và trực tuyến

Adobe MAX 2024

Adobe MAX
Hội thảo sáng tạo

14–16/10 Bãi biển Miami và trực tuyến

Adobe MAX

Hội thảo sáng tạo

14–16/10 Bãi biển Miami và trực tuyến