<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generating a TOC in Excel - formulas are being written as text in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74765#M8504</link>
    <description>Thanks! however I think I was not enough clear with this situation...&lt;BR /&gt;
&lt;BR /&gt;
I've got an excel file with a bunch of sheets, and every month i'll be adding/deleting some sheets. What my code does is:&lt;BR /&gt;
&lt;BR /&gt;
1) read all those sheets through a EXCEL LIBNAME and put them into a SAS table (that the SQL bit).&lt;BR /&gt;
2) Clear the content of the TOC sheet (if exist)&lt;BR /&gt;
3) Write back to excel all worksheet's name formatted as links/hiperlinks. Each link will point out one sheet.&lt;BR /&gt;
4) Clear the libname to release the file.&lt;BR /&gt;
&lt;BR /&gt;
Everything works fine a part from the following issue:&lt;BR /&gt;
&lt;BR /&gt;
Rather than getting this in every cell:&lt;BR /&gt;
=HYPERLINK("#"&amp;amp;CELL("address",'Dictionary Tables'!A1),"Dictionary Tables")&lt;BR /&gt;
&lt;BR /&gt;
I am getting this:&lt;BR /&gt;
'=HYPERLINK("#"&amp;amp;CELL("address",'Dictionary Tables'!A1),"Dictionary Tables")&lt;BR /&gt;
&lt;BR /&gt;
which is being read as text when actually is a formula.&lt;BR /&gt;
&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;</description>
    <pubDate>Thu, 19 Feb 2009 17:26:15 GMT</pubDate>
    <dc:creator>_Altons_</dc:creator>
    <dc:date>2009-02-19T17:26:15Z</dc:date>
    <item>
      <title>Generating a TOC in Excel - formulas are being written as text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74763#M8502</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am writing out a SAS data set which contains a TOC  to excel but all formulas are being interpretated as text due to a single quote at the beginning of the function.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
My code is below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%LET xlsinfo="C:\emp.xls";&lt;BR /&gt;
LIBNAME xls &amp;amp;xlsinfo VER=2002;&lt;BR /&gt;
&lt;BR /&gt;
Proc SQL;&lt;BR /&gt;
Create table mysheets as&lt;BR /&gt;
 	Select distinct tranwrd(scan(memname,1,'$'),"'","") as Sheetid&lt;BR /&gt;
	from sashelp.vstabvw where libname="XLS" and upcase(tranwrd(scan(memname,1,'$'),"'","")) ne "TOC";&lt;BR /&gt;
quit;&lt;BR /&gt;
proc datasets library=Xls nodetails; delete TOC 'TOC$'n; quit;&lt;BR /&gt;
&lt;BR /&gt;
Data xls.TOC ;&lt;BR /&gt;
	set mysheets;&lt;BR /&gt;
	link="=HYPERLINK("!!'"#"'!!'&amp;amp;CELL("address",'!!"'"!!strip(compbl(Sheetid))!!"'!A1),"!!'"'!!strip(Sheetid)!!'")';&lt;BR /&gt;
	drop sheetid;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
LIBNAME xls clear;&lt;BR /&gt;
&lt;BR /&gt;
Any ideas?</description>
      <pubDate>Thu, 19 Feb 2009 16:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74763#M8502</guid>
      <dc:creator>_Altons_</dc:creator>
      <dc:date>2009-02-19T16:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a TOC in Excel - formulas are being written as text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74764#M8503</link>
      <description>Hi:&lt;BR /&gt;
  Not sure what's up with your code. However, as an alternative, this code, using TAGSETS.EXCELXP does create a TOC as the first page of a multi-sheet workbook. I used the version of the ExcelXP tagset template dated (SAS 9.1.3, v1.75, 07/26/07). &lt;BR /&gt;
&lt;BR /&gt;
  How Excel wants the TOC link specified looks like this in the Spreadsheet Markup Language XML written by ExcelXP. Note that in the XML Markup, the contents link is set by the ss:HRef= attribute. &lt;BR /&gt;
&lt;BR /&gt;
But, I don't know how the LIBNAME engine for Excel generates an internal hyperlink. This might actually be a question for Tech Support.&lt;BR /&gt;
&lt;BR /&gt;
cynthia&lt;BR /&gt;
   &lt;BR /&gt;
Example of XML SpreadsheetML contents written by TAGSETS.ExcelXP:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&amp;lt;Worksheet ss:Name="Contents"&amp;gt;&lt;BR /&gt;
&amp;lt;Table ss:StyleID="_contents"&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
&amp;lt;Row&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentprocname"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentprocname" ss:HRef="allstuff3.xls#'Table 1 - Data Set SASHELP.CLAS'!A1"&amp;gt;&lt;BR /&gt;
&amp;lt;Data ss:Type="String"&amp;gt;Print&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;/Row&amp;gt;&lt;BR /&gt;
&amp;lt;Row&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem" ss:HRef="allstuff3.xls#'Table 1 - Data Set SASHELP.CLAS'!A1"&amp;gt;&lt;BR /&gt;
&amp;lt;Data ss:Type="String"&amp;gt;Data Set SASHELP.CLASS&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;/Row&amp;gt;&lt;BR /&gt;
&amp;lt;Row&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentprocname"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentprocname" ss:HRef="allstuff3.xls#'Table 2 - Summary statistics'!A1"&amp;gt;&lt;BR /&gt;
&amp;lt;Data ss:Type="String"&amp;gt;Means&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;/Row&amp;gt;&lt;BR /&gt;
&amp;lt;Row&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&lt;BR /&gt;
&amp;lt;Cell ss:StyleID="contentitem" ss:HRef="allstuff3.xls#'Table 2 - Summary statistics'!A1"&amp;gt;&lt;BR /&gt;
&amp;lt;Data ss:Type="String"&amp;gt;Summary statistics&amp;lt;/Data&amp;gt;&lt;BR /&gt;
&amp;lt;/Cell&amp;gt;&amp;lt;/Row&amp;gt;&lt;BR /&gt;
&amp;lt;/Table&amp;gt;&lt;BR /&gt;
&amp;lt;/Worksheet&amp;gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
              &lt;BR /&gt;
Code that generated the above XML (I do get a TOC in the file when Excel opens):              &lt;BR /&gt;
[pre]&lt;BR /&gt;
ods tagsets.excelxp file='allstuff2.xls'&lt;BR /&gt;
                    options(doc='Help' contents='yes')&lt;BR /&gt;
                     style=sasweb;&lt;BR /&gt;
                &lt;BR /&gt;
proc print data=sashelp.class;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
proc means data=sashelp.shoes;&lt;BR /&gt;
class region;&lt;BR /&gt;
var sales;&lt;BR /&gt;
run;&lt;BR /&gt;
                &lt;BR /&gt;
ods tagsets.excelxp close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 19 Feb 2009 17:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74764#M8503</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-02-19T17:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a TOC in Excel - formulas are being written as text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74765#M8504</link>
      <description>Thanks! however I think I was not enough clear with this situation...&lt;BR /&gt;
&lt;BR /&gt;
I've got an excel file with a bunch of sheets, and every month i'll be adding/deleting some sheets. What my code does is:&lt;BR /&gt;
&lt;BR /&gt;
1) read all those sheets through a EXCEL LIBNAME and put them into a SAS table (that the SQL bit).&lt;BR /&gt;
2) Clear the content of the TOC sheet (if exist)&lt;BR /&gt;
3) Write back to excel all worksheet's name formatted as links/hiperlinks. Each link will point out one sheet.&lt;BR /&gt;
4) Clear the libname to release the file.&lt;BR /&gt;
&lt;BR /&gt;
Everything works fine a part from the following issue:&lt;BR /&gt;
&lt;BR /&gt;
Rather than getting this in every cell:&lt;BR /&gt;
=HYPERLINK("#"&amp;amp;CELL("address",'Dictionary Tables'!A1),"Dictionary Tables")&lt;BR /&gt;
&lt;BR /&gt;
I am getting this:&lt;BR /&gt;
'=HYPERLINK("#"&amp;amp;CELL("address",'Dictionary Tables'!A1),"Dictionary Tables")&lt;BR /&gt;
&lt;BR /&gt;
which is being read as text when actually is a formula.&lt;BR /&gt;
&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;&lt;/B&gt;</description>
      <pubDate>Thu, 19 Feb 2009 17:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74765#M8504</guid>
      <dc:creator>_Altons_</dc:creator>
      <dc:date>2009-02-19T17:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a TOC in Excel - formulas are being written as text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74766#M8505</link>
      <description>At first glance of the SAS code you sent in your initial post, I can see that your LINK variable assignment starts with a double-quote, however it does not end with a same  double-quote (I see a single-quote in your code submitted).&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 19 Feb 2009 21:04:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74766#M8505</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-02-19T21:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generating a TOC in Excel - formulas are being written as text</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74767#M8506</link>
      <description>Well, I just found that the Excel engine does not have the capacity to write formulas into a cell...&lt;BR /&gt;
&lt;BR /&gt;
I may go then with either dde or vbs... :-s&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help.&lt;BR /&gt;
&lt;BR /&gt;
_Altons_</description>
      <pubDate>Fri, 20 Feb 2009 10:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Generating-a-TOC-in-Excel-formulas-are-being-written-as-text/m-p/74767#M8506</guid>
      <dc:creator>_Altons_</dc:creator>
      <dc:date>2009-02-20T10:25:28Z</dc:date>
    </item>
  </channel>
</rss>

