• TadeasB
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi,

I'm trying to generate XML via Visualforce, but visualforce is not nesting tags properly. I have got following VF page:

<apex:page standardStylesheets="false" controller="DController" contentType="application/xml#D.xls">{!xmlheader}
<apex:variable value="" var="n"/>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" 
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Author>SF</Author>
  <Version>15.00</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <AllowPNG/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    ...
 </ExcelWorkbook>

<Styles>
    ...
</Styles>

<Worksheet ss:Name="Objects">
    <Names>
        ...
    </Names>
    <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="{!objectList.size+1}" x:FullColumns="1"
   x:FullRows="1">
        
      <apex:repeat value="{!objectList}" var="o">
        <Row>
            <Cell ss:StyleID="s22"><Data ss:Type="String"><apex:outputText escape="false" value="{!HTMLENCODE(o.Name)}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
            <Cell ss:StyleID="s22"><Data ss:Type="Number"><apex:outputText escape="false" value="{!o.R_Count__c}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
            <Cell ss:StyleID="s22"><Data ss:Type="Number"><apex:outputText escape="false" value="{!o.F_size__c}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
        </Row>
      </apex:repeat>
    </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">   ...
 </WorksheetOptions>
</Worksheet>


<apex:outputPanel layout="none" rendered="true">
<Worksheet ss:Name="Fields">
    ...
</Worksheet>
</apex:outputPanel>

</Workbook>{!endFile}
</apex:page>

 The thing is, that outputed XML is damaged. Sometimes tags are missing and almost always some tags are ended too late. This code produces following structure:

...
<Styles>
    ...
</Styles>
<Worksheet ss:Name="Objects">
	...
	<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
	</WorksheetOptions>
  
<Worksheet ss:Name="Fields">
	...
	<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
	...
	<WorksheetOptions>
</Worksheet></Workbook>
</Worksheet>

 You can see </Worksheet> tag at end of file. I've tried to surround it with some text to see, what happens. This VF:

</WorksheetOptions>
asdf</Worksheet>asdf

 produces this in output XML:

asdf</WorksheetOptions>asdf

...

</Workbook>
</Worksheet>

 

Sometimes it helps if I surround whole section with <apex:ouputPanel layout="none"> but mostly it has no effect. Does someone has any idea?

Hi,

I'm trying to generate XML via Visualforce, but visualforce is not nesting tags properly. I have got following VF page:

<apex:page standardStylesheets="false" controller="DController" contentType="application/xml#D.xls">{!xmlheader}
<apex:variable value="" var="n"/>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" 
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Author>SF</Author>
  <Version>15.00</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <AllowPNG/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    ...
 </ExcelWorkbook>

<Styles>
    ...
</Styles>

<Worksheet ss:Name="Objects">
    <Names>
        ...
    </Names>
    <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="{!objectList.size+1}" x:FullColumns="1"
   x:FullRows="1">
        
      <apex:repeat value="{!objectList}" var="o">
        <Row>
            <Cell ss:StyleID="s22"><Data ss:Type="String"><apex:outputText escape="false" value="{!HTMLENCODE(o.Name)}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
            <Cell ss:StyleID="s22"><Data ss:Type="Number"><apex:outputText escape="false" value="{!o.R_Count__c}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
            <Cell ss:StyleID="s22"><Data ss:Type="Number"><apex:outputText escape="false" value="{!o.F_size__c}"/></Data>
                <NamedCell ss:Name="_FilterDatabase"/></Cell>
        </Row>
      </apex:repeat>
    </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">   ...
 </WorksheetOptions>
</Worksheet>


<apex:outputPanel layout="none" rendered="true">
<Worksheet ss:Name="Fields">
    ...
</Worksheet>
</apex:outputPanel>

</Workbook>{!endFile}
</apex:page>

 The thing is, that outputed XML is damaged. Sometimes tags are missing and almost always some tags are ended too late. This code produces following structure:

...
<Styles>
    ...
</Styles>
<Worksheet ss:Name="Objects">
	...
	<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
	</WorksheetOptions>
  
<Worksheet ss:Name="Fields">
	...
	<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
	...
	<WorksheetOptions>
</Worksheet></Workbook>
</Worksheet>

 You can see </Worksheet> tag at end of file. I've tried to surround it with some text to see, what happens. This VF:

</WorksheetOptions>
asdf</Worksheet>asdf

 produces this in output XML:

asdf</WorksheetOptions>asdf

...

</Workbook>
</Worksheet>

 

Sometimes it helps if I surround whole section with <apex:ouputPanel layout="none"> but mostly it has no effect. Does someone has any idea?