如何将整个页面转换为Excel格式 [英] How to convert whole page in excel format

查看:108
本文介绍了如何将整个页面转换为Excel格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,先生,
我正在尝试将整个页面转换为excel,我知道如何将Grid转换为excel,但这对我来说有点独特,请帮助我或赋予一些链接以便我可以做我的工作,我在google中找到但无法理解他们授予的代码请帮助我

整页转为Excel,请帮助先生的
预先感谢

Hello Sir,
I am trying to convert whole page into excel, I know how to convert Grid to excel, but this is bit unique for me please help me or confer some links so that I can do my work,I found in google but not able to understand the code they confered please help me

Whole Page to Excel Please help Sir''s
Thanks in advance

推荐答案

首先,您需要解析HTML以识别元素<table><tr><td>之间的关系,并从中提取HTML内容. <td>.如果您可以假设HTML是格式良好的XML,那么这很容易;您可以使用一种可用的XML解析器.

这是您可以使用的XML解析功能的简短回顾:
First, you need to parse HTML to recognize relationships between the elements <table>, <tr> and <td> and extract the HTML content from <td>. If you can assume your HTML is a well-formed XML, this is easy; you can use one of available XML parsers.

Here is a short review of XML parsing capabilities you can use:

  1. 使用System.Xml.XmlDocument类.它实现了DOM接口;如果文档太大,则这种方法最简单,也足够好.
    请参见
  2. 使用类System.Xml.XmlTextReader; library/system.xml.xmldocument.aspx"target =" _ blank"title =" New Window> ^ ].
  3. 使用类System.Xml.XmlTextReader;这是最快的读取方法,尤其是您需要跳过一些数据.
    请参见 http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx [ http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [http://msdn.microsoft.com/en-us/library/bb387063.aspx [

  1. Use System.Xml.XmlDocument class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].
  2. Use the class System.Xml.XmlTextReader; this is the fastest way of reading, especially is you need to skip some data.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^].
  3. Use the class System.Xml.Linq.XDocument; this is the most adequate way similar to that of XmlDocument, supporting LINQ to XML Programming.
    See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].



如果您不能在输入中采用格式正确的XML,那么这当然会更加困难.您可以使用一些可以处理此类输入的HTML解析器.例如,尝试以下操作:
http://www.majestic12.co.uk/projects/html_parser.php [^ ].

要创建Excel文档,您需要使用Microsoft Office互操作.从这里开始:
http://msdn.microsoft.com/en-us/library/wss56bz7%28v = VS.100%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/dd264733.aspx [ ^ ].

—SA



If you cannot assume well-formed XML on input, this is of course more difficult. You can use some HTML parser which can handle such input. Try, for example, this one: http://www.majestic12.co.uk/projects/html_parser.php[^].

To create Excel document you need to use Microsoft Office interop. Start here:
http://msdn.microsoft.com/en-us/library/wss56bz7%28v=VS.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/dd264733.aspx[^].

—SA


这篇关于如何将整个页面转换为Excel格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆