i have done excel to xml conversion like this but the problem is...if i
rename the "d:\database\terget.txt" to "d:\database\terget.xml" then the
file is not opening as a xml file & " The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and
then click the Refresh button, or try again later.
require 'parseexcel'
require 'win32ole'
require 'roo'
workbook = Spreadsheet::ParseExcel.parse('d:\source.xls')
worksheet = workbook.worksheet(0)
puts
@C = 0
@r = 0
@header = []
@fn=[]
skip = 0
worksheet.each(skip){|row|
first_cell = row
File.open('d:\test.txt','a') do |f|
if @r < 1
@C = first_cell.length
for l in 0...@C
@header[l] = first_cell[l].to_s('latin1')
end
end
@r = @r +1
end
}
skip =1
@cnt=0
worksheet.each(skip) { |row|
File.open('d:\database\terget.xml','a') do |file|
first_cell=row
for l in 0...@C
if first_cell[l] !=nil
str = first_cell[l].to_s('latin1')
else
str = ' '
end
file.puts "- <" + @header[l] + ">" + str + "</" +
@header[l]+ ">"
file.puts
end
end
@cnt= @cnt+1
}
Attachments:
http://www.ruby-forum.com/attachment/1723/xml.rb
Umm that's not an xml thing. The program displaying the xml may choose to do that, but that's absolutely not somthing that should be in the xml itself. (and it looks like that's what's causing your parse error)
Fred
but can u help me on that........................
if u can help me by submitting code in reply that will be realy helpfull
for me
its urgent please...............
but can u help me on that........................
if u can help me by submitting code in reply that will be realy
helpfull
for me
its urgent please...............
There is absolutely nothing that you can put in an xml file that will
make the elements be collapsable. xml just describes some data, it
doesn't care about how it's displayed. The program displaying the data
may choose to do nice things such as some form of syntax highlighting.
If you stick a bare xml document into firefox for example, you'll get
your collapsable nodes, because that's just how firefox likes to
display xml. If you need more then you could always right an xsl
stylesheet that transforms the xml into an html document with all the
GUI niceties that you want.
Fred
There is absolutely nothing that you can put in an xml file that will
make the elements be collapsable. xml just describes some data, it
doesn't care about how it's displayed. The program displaying the data
may choose to do nice things such as some form of syntax highlighting.
If you stick a bare xml document into firefox for example, you'll get
your collapsable nodes, because that's just how firefox likes to
display xml. If you need more then you could always right an xsl
stylesheet that transforms the xml into an html document with all the
GUI niceties that you want.
but in my project have to read excel file& i have to generate xml for
each row individualy…& all the xml should in a common file as i want
to do there…
now can u help me by submitting some code to me??
that will be really helpfuul to me
Which u want to say above i know that…but i can't reach the goal thats
why i am submitting the code,asked for solution…
can u help me(coding+advice) to solve it???
As far as the xml generation goes, you should probably look a something like builder (as it is you could very easily be generating invalid xml if the cells contain any of the forbidden characters.
Fred
plz provide some code/example