# Xml freeze pane and column width

**URL:** <https://www.ruby-forum.com/t/xml-freeze-pane-and-column-width/74014>\
**Category:** Rails\
**Created:** [October 29, 2006, 7:16am UTC](https://www.ruby-forum.com/t/xml-freeze-pane-and-column-width/74014 "2006-10-29T07:16:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![darrenevans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@darrenevans](https://www.ruby-forum.com/u/darrenevans)\
**Post date:** [October 29, 2006, 7:16am UTC](https://www.ruby-forum.com/t/xml-freeze-pane-and-column-width/74014/1 "2006-10-29T07:16:59Z")

</div>

Hi

I have generated an xml export using ruby on rails. There are two things  
that I have not be able to do. The first is to freeze the header pane  
(after a look around, I think that this may not be possible?) and the  
second is to let the column width to be changed for columns as I define  
(a line of code for each column, because they should all be different  
widths).

Does anyone have experience with this? My difficulties come at around  
line 45 of the following.

Many thanks

Darren

#This file is used to convert data from the database into an xml flow,  
so that the data can be exported in an excel format: added by Darren  
Evans, October 2006  
xml.instruct! :xml, :version=\>“1.0”, :encoding=\>“UTF-8”  
xml.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:html’ =\> “[http://www.w3.org/TR/REC-html40](http://www.w3.org/TR/REC-html40)”,  
‘xmlns:ss’ =\> “urn:schemas-microsoft-com:office:spreadsheet”

}) do

xml.Styles do  
xml.Style ‘ss:ID’ =\> ‘Default’, ‘ss:Name’ =\> ‘Normal’ do  
xml.Alignment ‘ss:Vertical’ =\> ‘Bottom’, ‘ss:Horizontal’ =\> ‘Left’  
xml.Borders  
xml.Font ‘ss:FontName’ =\> ‘Verdana’  
xml.Interior  
xml.NumberFormat  
xml.Protection

end

xml.Style ‘ss:ID’ =\> ‘s22’ do  
xml.NumberFormat ‘ss:Format’ =\> ‘General Date’  
end

xml.Style ‘ss:ID’ =\> ‘s21’, ‘ss:Name’ =\> ‘Bold’ do  
xml.Alignment ‘ss:Vertical’ =\> ‘Bottom’, ‘ss:Horizontal’ =\> ‘Left’  
xml.Borders  
xml.Font ‘ss:FontName’ =\> ‘Verdana’, ‘ss:Bold’ =\> ‘1’  
xml.Interior  
xml.NumberFormat  
xml.Protection  
end

end

xml.Worksheet ‘ss:Name’ =\> ‘Price List’ do  
xml.Table ‘ss:DefaultColumnWidth’=\> ‘200’ do

```
  # Header
  xml.Row 'ss:StyleID' => 's21' do
    for column in Product.content_columns do

       if (column.human_name!="Id") && 

```

(column.human\_name!=“Identity”) && (column.human\_name!=“Position”) &&  
(column.human\_name!=“Active”) && (column.human\_name!=“Section”) &&  
(column.human\_name!=“Subsection”) &&  
(column.human\_name!=“Subsubsection”) && (column.human\_name!=“Updated  
at”) && (column.human\_name!=“Updated by”)  
xml.Cell do  
xml.Data column.human\_name, ‘ss:Type’ =\> ‘String’  
end  
end  
end

```
    for column in @categories do
      xml.Cell do
        xml.Data column.name+" ("+session[:currency_name]+")", 

```

‘ss:Type’ =\> ‘String’  
end  
end  
end  
# Rows  
for product in @export  
xml.Row do  
for column in Product.content\_columns do  
if (column.human\_name!=“Id”) &&  
(column.human\_name!=“Identity”) && (column.human\_name!=“Position”) &&  
(column.human\_name!=“Active”) && (column.human\_name!=“Section”) &&  
(column.human\_name!=“Subsection”) &&  
(column.human\_name!=“Subsubsection”) && (column.human\_name!=“Updated  
at”) && (column.human\_name!=“Updated by”)  
xml.Cell do  
if (column.human\_name!=“Ata”) &&  
(column.human\_name!=“Minimum quantity”) && (column.human\_name!=“Standard  
lead time”)&& (column.human\_name!=“Mtbf”) && (column.human\_name!=“Repair  
tat”) && (column.human\_name!=“Overhaul tat”)  
xml.Data product.send(column.name), ‘ss:Type’ =\> ‘String’  
else  
xml.Data product.send(column.name), ‘ss:Type’ =\> ‘Number’  
end

```
          end
       end
      end
    @prices=Price.find(:all, :conditions => ["currencies_id = ? AND 

```

products\_id = ?", session[:currency\_id], product.id])  
count=1  
for price in @prices do  
if ((price.categories\_id==2) &&  
(session[:currency\_name]!=“CHF”))  
xml.Cell do  
xml.Data “-”, ‘ss:Type’ =\> ‘String’  
end  
end

```
        xml.Cell do
          if(price.value!="-")
            xml.Data price.value, 'ss:Type' => 'String'
          else
            xml.Data "-", 'ss:Type' => 'String'
          end
        end

        if ((price.categories_id==1) && 

```

(session[:currency\_name]!=“CHF”))  
3.times do  
xml.Cell do  
xml.Data “-”, ‘ss:Type’ =\> ‘String’  
end  
end  
end  
end  
end  
end  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![darrenevans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@darrenevans](https://www.ruby-forum.com/u/darrenevans)\
**Post date:** [October 29, 2006, 7:22am UTC](https://www.ruby-forum.com/t/xml-freeze-pane-and-column-width/74014/2 "2006-10-29T07:22:27Z")

</div>

Hi

I have generated an xml export using ruby on rails. There are two things  
that I have not be able to do. The first is to freeze the header pane  
(after a look around, I think that this may not be possible?) and the  
second is to let the column width to be changed for columns as I define  
(a line of code for each column, because they should all be different  
widths).

Does anyone have experience with this? My difficulties come at around  
line 45 of the following.

Many thanks

Darren

#This file is used to convert data from the database into an xml flow,  
so that the data can be exported in an excel format: added by Darren  
Evans, October 2006  
xml.instruct! :xml, :version=\>“1.0”, :encoding=\>“UTF-8”  
xml.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”  
}) do

xml.Styles do  
xml.Style ‘ss:ID’ =\> ‘Default’, ‘ss:Name’ =\> ‘Normal’ do  
xml.Alignment ‘ss:Vertical’ =\> ‘Bottom’, ‘ss:Horizontal’ =\> ‘Left’  
xml.Borders  
xml.Font ‘ss:FontName’ =\> ‘Verdana’  
xml.Interior  
xml.NumberFormat  
xml.Protection  
end

xml.Style ‘ss:ID’ =\> ‘s22’ do  
xml.NumberFormat ‘ss:Format’ =\> ‘General Date’  
end

xml.Style ‘ss:ID’ =\> ‘s21’, ‘ss:Name’ =\> ‘Bold’ do  
xml.Alignment ‘ss:Vertical’ =\> ‘Bottom’, ‘ss:Horizontal’ =\> ‘Left’  
xml.Borders  
xml.Font ‘ss:FontName’ =\> ‘Verdana’, ‘ss:Bold’ =\> ‘1’  
xml.Interior  
xml.NumberFormat  
xml.Protection  
end  
end

xml.Worksheet ‘ss:Name’ =\> ‘Vibro-Meter Price List’ do  
xml.Table ‘ss:DefaultColumnWidth’=\> ‘200’ do  
# Header  
xml.Row ‘ss:StyleID’ =\> ‘s21’ do  
for column in Product.content\_columns do

```
       if (column.human_name!="Id") && 

```

(column.human\_name!=“Identity”) && (column.human\_name!=“Position”) &&  
(column.human\_name!=“Active”) && (column.human\_name!=“Section”) &&  
(column.human\_name!=“Subsection”) &&  
(column.human\_name!=“Subsubsection”) && (column.human\_name!=“Updated  
at”) && (column.human\_name!=“Updated by”)  
xml.Cell do  
xml.Data column.human\_name, ‘ss:Type’ =\> ‘String’  
end  
end  
end

```
    for column in @categories do
      xml.Cell do
        xml.Data column.name+" ("+session[:currency_name]+")", 

```

‘ss:Type’ =\> ‘String’  
end  
end  
end  
# Rows  
for product in @export  
xml.Row do  
for column in Product.content\_columns do  
if (column.human\_name!=“Id”) &&  
(column.human\_name!=“Identity”) && (column.human\_name!=“Position”) &&  
(column.human\_name!=“Active”) && (column.human\_name!=“Section”) &&  
(column.human\_name!=“Subsection”) &&  
(column.human\_name!=“Subsubsection”) && (column.human\_name!=“Updated  
at”) && (column.human\_name!=“Updated by”)  
xml.Cell do  
if (column.human\_name!=“Ata”) &&  
(column.human\_name!=“Minimum quantity”) && (column.human\_name!=“Standard  
lead time”)&& (column.human\_name!=“Mtbf”) && (column.human\_name!=“Repair  
tat”) && (column.human\_name!=“Overhaul tat”)  
xml.Data product.send(column.name), ‘ss:Type’ =\> ‘String’  
else  
xml.Data product.send(column.name), ‘ss:Type’ =\> ‘Number’  
end

```
          end
       end
      end
    @prices=Price.find(:all, :conditions => ["currencies_id = ? AND 

```

products\_id = ?", session[:currency\_id], product.id])  
count=1  
for price in @prices do  
if ((price.categories\_id==2) &&  
(session[:currency\_name]!=“CHF”))  
xml.Cell do  
xml.Data “-”, ‘ss:Type’ =\> ‘String’  
end  
end

```
        xml.Cell do
          if(price.value!="-")
            xml.Data price.value, 'ss:Type' => 'String'
          else
            xml.Data "-", 'ss:Type' => 'String'
          end
        end

        if ((price.categories_id==1) && 

```

(session[:currency\_name]!=“CHF”))  
3.times do  
xml.Cell do  
xml.Data “-”, ‘ss:Type’ =\> ‘String’  
end  
end  
end  
end  
end  
end  
end  
end  
end
