免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5410 | 回复: 7
打印 上一主题 下一主题

关于shell生成xml文件的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-23 22:38 |只看该作者 |倒序浏览
大家好:
shell有什么办法生成xml文件,用windows的execl也可以打开。
比如下面一段代码:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-comffice:spreadsheet"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns="urn:schemas-microsoft-comffice:excel"
xmlns:ss="urn:schemas-microsoft-comffice:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-comfficeffice">
  <LastPrinted>2008-05-21T02:05:01Z</LastPrinted>
  <Created>1996-12-17T01:32:42Z</Created>
  <LastSaved>2008-05-21T01:55:55Z</LastSaved>
  <Version>11.6568</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-comfficeffice">
  <RemovePersonalInformation/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>8775</WindowHeight>
  <WindowWidth>15360</WindowWidth>
  <WindowTopX>-30</WindowTopX>
  <WindowTopY>1260</WindowTopY>
  <TabRatio>212</TabRatio>
  <rotectStructure>False</ProtectStructure>
  <rotectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
   <Interior/>
   <NumberFormat/>
   <rotection/>
  </Style>
  <Style ss:ID="s21" ss:Name="常规_1月16日">
   <Alignment ss:Vertical="Center"/>
   <Borders/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
   <Interior/>
   <NumberFormat/>
   <rotection/>
  </Style>
  <Style ss:ID="s22" ss:Name="常规_1月24日">
   <Alignment ss:Vertical="Center"/>
   <Borders/>
   <Font ss:FontName="宋体" x:CharSet="134" ss:Size="12"/>
   <Interior/>
   <NumberFormat/>
   <rotection/>
  </Style>
  <Style ss:ID="m20261720">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ssosition="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ssosition="Left" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ssosition="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ssosition="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
   </Borders>
   <Font ss:FontName="宋体" x:CharSet="134"/>
  </Style>
  <Style ss:ID="m20261730">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1"/>
   <Borders>
    <Border ssosition="Bottom" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ssosition="Left" ss:LineStyle="Continuous" ss:Weight="2"/>
    <Border ssosition="Right" ss:LineStyle="Continuous" ss:Weight="2"/>
   </Borders>
  </Style>
  <Style ss:ID="m20261740" ssarent="s22">
   <Alignment ss:Horizontal="Center" ss:Vertical="Center"/>
   <Borders>
    <Border ssosition="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ssosition="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
    <Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
   </Borders>
   <Font ss:FontName="宋体" x:CharSet="134"/>
   <NumberFormat ss:Format="@"/>
  </Style>

这个是看我们老大在hp-ux上写的,现在需要用shell生成一个值班表可用Excel打开的xml文件。问一下各位高手有什么好方法可以自动生成xml,还是只能一行行写。
还请各位高手给指点一下,谢谢了。

论坛徽章:
0
2 [报告]
发表于 2009-04-23 22:53 |只看该作者
能用excel打开的xml格式是怎么样的呢?

论坛徽章:
0
3 [报告]
发表于 2009-04-24 08:34 |只看该作者

回复 #1 coco_andy 的帖子

这个得至少知道源文件是怎么样的,目标文件大概是怎么样的吧。
要不然很多人都不知道怎么搞。。

论坛徽章:
0
4 [报告]
发表于 2009-04-24 15:06 |只看该作者
是呀,看了老大写的那个shell脚本,他是有一个xml的模版文件,我上面贴出来的是模版的开头部分。

论坛徽章:
0
5 [报告]
发表于 2009-04-24 19:31 |只看该作者
MS的excel吗?
好像不是明文文本的吧

论坛徽章:
0
6 [报告]
发表于 2009-04-24 23:37 |只看该作者
恩,他是用一个xml模板,把每天统计的cpu利用率和memory利用率,填到xml模版后,生成xml文件用samba传到windows里,用execl打开就是一个表格文件。我上面贴出来的内容就是xml模版开头的部分。

论坛徽章:
0
7 [报告]
发表于 2009-04-25 15:12 |只看该作者
给你一个建议,先用execl生成一个新的xls文件,然后里面加一些参考数据,最后保存成xml文件

然后分析一下那个文件,你就知道应该如何写了

我在程序中就是那么处理的,生成特殊格式的xml文件,excel可以直接打开

不过,这种方式有些限制,只能保存一些基本的数据,象公式、图片等就不行了

论坛徽章:
0
8 [报告]
发表于 2009-05-04 01:06 |只看该作者
谢谢 springwind426大哥了,我用execl保存成xml文件,在把相应位置的值代替就可以了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP