小编Ata*_*kov的帖子

在单独的工作表中将HTML表导出到Excel(.xls)

我有一个包含表视图的简单HTML页面(由外部应用程序生成).我试图从页面中删除表格并将它们放在Excel工作簿中.我已经设法使用此处提供的方法将整个HTML内容放在工作簿中.

相关问题的代码:

var tableToExcel = (function() {
  var uri = 'data:application/vnd.ms-excel;base64,'
    , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
    , base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
    , format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
  return function(table, name) {
    if (!table.nodeType) table = document.getElementById(table)
    var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
    window.location.href = uri + base64(format(template, ctx))
  }
})()
Run Code Online (Sandbox Code Playgroud)

但是,该方法不支持多个电子表格.我需要的是在同一个Excel工作簿中的每个HTML表格中都有自己的SpreadSheet.像这样的东西: 在此输入图像描述

我试图用两个电子表格创建一个示例Excel文档,然后通过查看.html格式的导出对其进行反向工程.不幸的是,我无法理解如何重新创建工作簿和工作表之间的连接.

据我所知,该format()功能将工作表数据和Excel模板的"魔法"结合起来.这个功能对我来说看起来很神秘,所以我不知道如何修改它.

作为终极游戏我需要的是有可能打电话. tableToExcel(document.getElementsByTagName('table'), …

html javascript excel xls html-table

12
推荐指数
1
解决办法
5万
查看次数

使用 Parsec 解析数据并省略注释

我正在尝试编写一个 Haksell Parsec Parser,它将文件中的输入数据解析为 LogLine 数据类型,如下所示:

--Final parser that holds the indvidual parsers.
final :: Parser [LogLine]
final = do{ logLines <- sepBy1 logLine eol
        ; return logLines
        }


--The logline token declaration
logLine :: Parser LogLine
logLine = do
name <-  plainValue -- parse the name (identifier)
many1 space -- parse and throw away a space
args1 <- bracketedValue -- parse the first arguments
many1 space -- throw away the second sapce
args2 <- bracketedValue -- parse the second …
Run Code Online (Sandbox Code Playgroud)

parsing haskell parsec

5
推荐指数
1
解决办法
2235
查看次数

Haskell中嵌套的`do`块

我正在尝试在Haskell中编写一个函数来检查一些事情,然后根据一些最小的用户输入进行递归.为了做到这一点,我想我必须使用do块.

cip :: [Argument] -> [Argument] -> Bool -> Bool -> IO()
cip (a:args) pargs burden gameover = do
    let nasko = a:pargs
    putStrLn (getPremise a)
    let newgraph = Carneades.mkArgGraph nasko
    let newcaes = (CAES (newgraph,audience2,assStandarts)) 
    let answer = (acceptable (mkProp (getPremise a)) newcaes )
    print answer
    if(answer==True) 
    then (cip args nasko burden gameover) 
    else do
        print "One of the arguments is not proved. Here are the premises that need proving"
        print (propsForFixing newcaes a)
        print "Let's see …
Run Code Online (Sandbox Code Playgroud)

haskell

4
推荐指数
1
解决办法
2398
查看次数

通过SimpleXML PHP编辑XML节点

我知道有几次问过类似的问题,但我无法找到以下解决方案:

我有一个简单的XML文件:servers.xml

<servers>

    <server>
        <name> Google </name>
        <address>http://www.google.com</address>
    </server>

    <server> 
        <name> Yahoo </name>
        <address>http://www.yahoo.com</address>
    </server>

    <server>
        <name> Bing </name>
        <address>http://www.bing.com</address>
    </server>

</servers>
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试获取<server>名称为"Google" 的节点,然后更改地址标记.我不知道如何使用SimpleXML去做.因此,示例场景如下:

  1. 获取服务器对象/数组,其中$ serverName ="Google"
  2. 将服务器的地址字段编辑为与http://www.google.co.uk不同的地方
  3. 将更改写回XML文件.

任何帮助,将不胜感激.

php xml simplexml xml-parsing

1
推荐指数
1
解决办法
4224
查看次数

标签 统计

haskell ×2

excel ×1

html ×1

html-table ×1

javascript ×1

parsec ×1

parsing ×1

php ×1

simplexml ×1

xls ×1

xml ×1

xml-parsing ×1