6 Replies Latest reply on Dec 18, 2013 9:17 AM by Eugene Tyson

    Help: How to format lots of numbers with a GREP style

    pireatesgold

      Hi there,

       

      I am using XML to bring a lot of data into InDesign from an Access database.  I want to autogenerate demographic "fact sheets" about a bunch of neighborhoods.  Since I'm a total noob at this workflow, I'm having trouble figuring out how to format the numbers I'm bringing in.  As an example, right now I have -7.03129508372747E-02, which I need to format as -7.0%,  Is there a way to define a GREP style that can do this for me?  I also need to be able to put in commas or $ in some cases.  Since there are thousands of numbers here, I need to be able to do it automatically.  Help me, internet!

       

      Thanks very much,

       

      Elizabeth

        • 1. Re: Help: How to format lots of numbers with a GREP style
          Eugene Tyson Adobe Community Professional & MVP

          Hi Elizabeth

           

          Grep Styles cannot replace text.

           

          It can only apply a Style, like bold or Italic to the text.

           

          You'd be better off importing the text to Excel first - having it apply a Percent and decimal placement in the cell there.

           

          Then import the excel sheet into InDesign.

           

           

          I'm afraid what you're asking to do with Grep Styles is just not possible as it's not designed for that.

           

           

          However it might be possible to Script what you want.

           

          http://forums.adobe.com/community/indesign/indesign_scripting

          • 2. Re: Help: How to format lots of numbers with a GREP style
            pireatesgold Level 1

            Thanks for the quick response!  As I understand it, the problem with applying formatting in excel is that there the numbers simply APPEAR to be smaller.  When you export them to XML, the formatting doesn't come with.  Is there a smart way to get around this problem?  Surley tons of people must use an automated proess to layout pages of numbers in InDesign.

            • 3. Re: Help: How to format lots of numbers with a GREP style
              John Mensinger Adobe Community Professional & MVP

              pireatesgold wrote:

               

              Surley tons of people must use an automated proess to layout pages of numbers in InDesign.

               

              True or not, InDesign by itself is not capable of applying or performing mathematical operations on the contents of text frames.

               

              So, the next step, (for us here on the forum), might be to examine the reasons you're using XML rather than placing "static" content in InDesign. Are your fact sheets to be dynamic going forward?

              • 4. Re: Help: How to format lots of numbers with a GREP style
                Eugene Tyson Adobe Community Professional & MVP

                When I created the Excel test file I imported the Excel file to InDesign and the number came in as -7.0%

                 

                I don't know about maybe using the XML Map feature in Excel?

                 

                 

                I don't know enough about what you're doing to really help.

                • 5. Re: Help: How to format lots of numbers with a GREP style
                  pireatesgold Level 1

                  Sure - thanks for your help.  Maybe there's a better way to do this overall that I'm not aware of.  So I have a database in essentially this format: (only much, much bigger--a couple hundred rows and 163 columns)

                   

                  GeographyTotal_Population_2000Total_Population_2010Total_Population_CHANGE
                  156,79152,798-7.0%
                  253,46564,63720.9%
                  351,32236,914-28.1%
                  451,30441,647-18.8%

                   

                  I was thinking it could work to use XML to merge everything so that I have a template with all the indicators, and then the first page is all geography 1, second page all geography 2 and so on.  The last time I did this, I used SAP Crystal Reports which was super cludgy and made an ugly product it took me hours to clean up in InDesign.  Would it be better to try to accomplish this with a data merge?  Can you get number formats in that way?  I really only have experience using InDesign to layout books, reports, invitations etc.  This is the first time I'm using it as part of a more robust process, so please forgive my awkward questions.

                   

                  Re: dynamic content, I was vaguely thinking that if I could get this right, it might be easier to beg someone to help me make a little tool to make the info easily searchable on our website.  It's certainly not essential, though, and may be me reaching too far past my skills.  I just want to figure out the best way to make a spreadsheet become a bunch of fact sheets that look neat and nice.

                  • 6. Re: Help: How to format lots of numbers with a GREP style
                    Eugene Tyson Adobe Community Professional & MVP

                    A data merge should be better.

                     

                    And it should import the numbers as you describe.

                     

                    Only way to know is to try.