TechSpoken
"Any ideas?" is the most frequently-asked question in technical forums. My answer is: yes.

YAPS (Yet another postscript) on Custom Excel for RS

April 18, 2008 14:11 by LSN

I really can't believe I'm revisiting this subject... I thought I was done with it ... but this is worth saying because it's helpful to anybody generating SSML (Excel 2003 XML dialect) whether they are interested in RS or not.  I also can't believe I never figured this out before -- because I generate a lot of SSML, for all kinds of custom reports.

So last time I said this 

[...] It also happens to be a situation, alluded to in my walkthrough, where you have to be careful that your dynamically-driven tab names are actually legal tab names in Excel.  In this case, I used the following code to validate and change the tab names if necessary:

<xsl:template name="StripSheetName">
      <xsl:param name="item"/>
      <xsl:variable name="i1">
         <xsl:value-of select="translate($item,'&quot;“”','')"/>
      </xsl:variable>
      <xsl:value-of select="translate($i1,&quot;/\'&quot;,&quot;&quot;)"/>
</xsl:template>

... looks a bit wierd and it may not turn out to be sufficient, but basically all I'm doing is taking out characters I know to be illegal.  If I find more, I'll add more.

Guess what?  It didn't turn out to be sufficient. 

The items I'm using for tab names in this report are particularly long and (who knew?) Excel has a tab name limit of 31 characters. Before you ask, it's not in the Excel specifications and limits page as far as I can see. 

Also before you ask I figured out the exact number by typing 1234512345123451234512345123451 into a tab.  That last "1" is the last character Excel will let you type.  If anybody has a better source of information, I'm all ears.

So, I smartened up the template you see above a little bit.  In this particular workbook, we're adding some verbiage onto the end of entries for each tab, which you'll see referenced; other than that, you may be able to use this puppy. 

I'm stripping blank spaces out to conserve some tablength room in this version; this isn't required, because spaces are allowed in tab names, but I was trying to save some room for more meaningful content.   You'll also notice a use of two dots ("..") wherever I'm truncating a tab name, and your strategy might be slightly different... 

In any case, all-in-all, something like this should work for you.

 <xsl:template name="StripSheetName">

      <xsl:param name="item"/>
     <xsl:param name ="secondTable"/>

     <!-- get rid of smart quote and quote marks, not allowed
           and remove spaces too, to save room -->

      <xsl:variable name="i1">
         <xsl:value-of select="translate($item,' &quot;“”','')"/>
      </xsl:variable>

     <!-- get rid of other disallowed characters, including
            single-quote (apostrophe) -->

     <xsl:variable name="i2" select="translate($i1,&quot;/\'&quot;,&quot;&quot;)"/>

     <xsl:variable name="i3" >
       <xsl:choose>
         <xsl:when test="string-length($i2) &gt; 20">
         <!-- truncate, leaving enough spare room for suffix,
                and add dots -->

           <xsl:value-of select ="concat(substring($i2,1,18),'..')"/>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select ="$i2"/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>

    <!-- add appropriate suffix for this tab -->
     <xsl:choose>
       <xsl:when test ="$secondTable">
         <xsl:value-of select ="concat($i3,'ByActivity')"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select ="concat($i3,'ByCategory')"/>
       </xsl:otherwise>
     </xsl:choose>

   </xsl:template>

 

Also before you ask: what you see up there with escaped characters is correct (for example where you see &gt; (for greater than, in XSLT) that's not an error of HTML formatting. 

The parts that look especially weird come from explicitly specifying delimiters, such as quotation marks, as string literals, but this really does work, and you may really need to do it now and again.

Enjoy... and god bless Excel and all its peculiarities <sob>.


Comments

September 2. 2008 22:01

trackback

Trackback from Urlrecorder - URL sharing

Ssml Urls

Urlrecorder - URL sharing

September 13. 2008 01:01

trackback

Trackback from Urlrecorder - URL sharing

Ssml Urls

Urlrecorder - URL sharing

November 4. 2008 23:48

Tom Xie

Hi Lisa,
Thank you for this passage, and I think there are some missing invalid chars in the utility. <g>
I've added them as the following:
<xsl:variable name="i2" select="translate($i1,&quot;/\':*?[]&quot;,&quot;&quot;)"/>

Hope it helps, thank you

Tom Xie

November 4. 2008 23:50

>L<

Thank you Tom!  Like the length of the tab name, this isn't documented anywhere that I could find.  So I only find out about illegal characters by trial and error <g>.  Thank you for saving me some trial and error!

>L<

June 24. 2009 09:36

Quick Payday Loan

No matter what did you say. you did the great jobs..
Congratulation!

Quick Payday Loan

July 8. 2009 18:05

Contractor for Roofs

Nice blog, just bookmarked it for later reference

Contractor for Roofs

July 9. 2009 04:48

Dustin

This is new info for me Thanks.

Dustin

August 16. 2009 04:37

Calling Cards USA

Thanks, you cleared up some things for me.

Calling Cards USA

August 22. 2009 07:09

Book Publisher UK

As helpful as ever, thanks!

Book Publisher UK

August 23. 2009 19:16

atlix

A++ post will read again

atlix

November 22. 2009 05:37

excel expert

Excel 2003 XML dialect in which application is it suitable?

excel expert

November 23. 2009 11:28

book publishers uk

the more YAPS the better in my mind. They all bring slightly different things to the table

book publishers uk

December 16. 2009 00:33

denver dui lawyer

I never hear about YAPS. YAPS (Yet another postscript) on Custom Excel for RS  - I want to try out your code... Smile

denver dui lawyer

January 25. 2010 20:19

non surgican hair transplantations

Thanks a lot for this extremely cool article.

non surgican hair transplantations

February 2. 2010 15:09

Extenze

You post saved me from a great trouble. I am very mush thankful to you for this.

Extenze

February 16. 2010 13:20

ps3magic

great post, helped me a lot, i was searching for this for weeks now. great share. bookmarked!

ps3magic

February 24. 2010 03:31

Car Rental & Car Hire Gold Coast

Well, I never know those SSML codes and also how and where to use it.  Better if you provided some more description for the innocent people.

Car Rental & Car Hire Gold Coast

February 25. 2010 02:59

sleep dentist

I have the same issue, the only difference is that I divided my report into multiple pages (using the insert page brak after rectangles) and I need to name the sheets in Excel.Any help will be appreciated.

sleep dentist

February 25. 2010 10:22

>L<

GamesRadar.smith, if you're real, the original post in this series does exactly that.

>L<

February 28. 2010 09:14

Karen Norman

I am fairly new to these excel scripts and find it fascinating, I now need to go and give it a go, thanks for some useful insight.

Karen Norman

March 19. 2010 19:26

electric adjustable beds

I started to try looking for documentation on the topic, also for a tool to help me debug the problems there. Thanks so much for your sharing.

electric adjustable beds

March 29. 2010 02:45

custom usb

You have got some great posts in your blog. I will be visiting again.

custom usb

April 28. 2010 12:15

Amazon Price Changes

SSML generation has always confused me a bit, this cleared some things up for me. Thank you for this.

Amazon Price Changes

May 22. 2010 04:44

Voluntary Insurance

I really aprreciate your work.You had done a lot of hard work on the blog.good work

Voluntary Insurance

May 25. 2010 08:13

Life Settlement

You had given me a lot of new ideas .i am really thankfull to you and to your team for the support.

Life Settlement

May 28. 2010 05:27

apartamentos amoblados panama

I started to try looking for documentation on the topic, also for a tool to help me debug the problems there. Thanks so much for your sharing.

apartamentos amoblados panama

June 4. 2010 04:02

Sterling Silver Necklaces

Thanks for taking this opportunity to discuss  this, I feel  fervently about this and I like learning about this subject.  If possible, as you gain information, please update  this blog with more information.  I have found it really useful.

Sterling Silver Necklaces

June 4. 2010 04:57

Silver Key Necklace

Took me a lot of time to read all the comments, but I really liked the article. It was very helpful to me. It's always cool when you can not only be informed, but also entertained! I'm sure you had good time writing this post.

Silver Key Necklace

June 7. 2010 22:56

massage

Very Good work, Keep the work going, I enjoyed reading the entire article and it made me happy....

massage

June 20. 2010 03:26

best internet tv software

Do you have any additional info on this? Or maybe point me into the correct direction?

best internet tv software

July 14. 2010 04:53

piano tutorial

it worked for me Lisa with the little change Tom suggested, thanks.

piano tutorial

July 20. 2010 03:47

network media players

I'm glad you went through the trouble of writing this up and posting it. It really helped me.

network media players

July 24. 2010 18:35

Wolf Jewelry

Absolutely fantastic article...custom excel is the best ;)

Wolf Jewelry

July 26. 2010 19:53

trackback

YAPS on Excel Tabs in SSRS: What a difference 2008 R2 makes... or doesn't

YAPS on Excel Tabs in SSRS: What a difference 2008 R2 makes... or doesn't

TechSpoken

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha

biuquote
  • Comment
  • Preview
Loading