Ios 将iPython笔记本中的表格复制到Word中?

Ios 将iPython笔记本中的表格复制到Word中?,ios,ms-word,ipython,Ios,Ms Word,Ipython,我想把iPython笔记本上的一张表复制到Word文档中。我正在使用Word for Mac 2011。该表是标准输出,如下所示: -- you may need to fix up the application name -- (I use this to ensure that the script uses the Open Word 2011 doc -- and does not try to start Word for Mac 15 (2016)) tell applicatio

我想把iPython笔记本上的一张表复制到Word文档中。我正在使用Word for Mac 2011。该表是标准输出,如下所示:

-- you may need to fix up the application name
-- (I use this to ensure that the script uses the Open Word 2011 doc
-- and does not try to start Word for Mac 15 (2016))
tell application "/Applications/Microsoft Office 2011/Microsoft Word.app"
    tell the paragraph format of the text object of table 1 of the text object of the selection
        set paragraph format left indent to 0
        set paragraph format right indent to 0
        set space before to 0
        set space after to 0
        set line spacing rule to line space single
    end tell
end tell
如果我使用Apple+C复制表格,然后将其粘贴到Word文档中,我会得到以下结果:

肯定有更简单的方法吗

在Word中创建具有相同行/列数的表,然后尝试将单元格粘贴到该表中也不起作用


我想我可以截屏表格,但如果可能的话,我想在文档中包含原始数据

从单词的角度来看,这种情况下的问题不是表格布局,而是段落布局。每个段落的左右两侧都有一个大的缩进,前后的空间比您通常想要的要大

我不认为任何粘贴选项(例如Word中的“粘贴特殊”选项)都会有帮助,除非您粘贴为未格式化文本,然后选择文本,转换为表格,然后从那里继续

但是,即使像这样一个简单的单词VBA宏也会给您带来一些更易于管理的东西。选择复制的表,然后运行宏。在代码上多做一点工作可能会让您在大多数情况下获得所需的大部分格式

Sub fixupSelectedTable()
With Selection.Tables(1).Range.ParagraphFormat
  .LeftIndent = 0
  .RightIndent = 0
  .SpaceBefore = 0
  .SpaceAfter = 0
  .LineSpacingRule = wdLineSpaceSingle
End With
End Sub  
如果您对Applescript更为熟悉,则其等效项如下所示:

-- you may need to fix up the application name
-- (I use this to ensure that the script uses the Open Word 2011 doc
-- and does not try to start Word for Mac 15 (2016))
tell application "/Applications/Microsoft Office 2011/Microsoft Word.app"
    tell the paragraph format of the text object of table 1 of the text object of the selection
        set paragraph format left indent to 0
        set paragraph format right indent to 0
        set space before to 0
        set space after to 0
        set line spacing rule to line space single
    end tell
end tell

从单词的角度来看,本例中的问题不是表格布局,而是段落布局。每个段落的左右两侧都有一个大的缩进,前后的空间比您通常想要的要大

我不认为任何粘贴选项(例如Word中的“粘贴特殊”选项)都会有帮助,除非您粘贴为未格式化文本,然后选择文本,转换为表格,然后从那里继续

但是,即使像这样一个简单的单词VBA宏也会给您带来一些更易于管理的东西。选择复制的表,然后运行宏。在代码上多做一点工作可能会让您在大多数情况下获得所需的大部分格式

Sub fixupSelectedTable()
With Selection.Tables(1).Range.ParagraphFormat
  .LeftIndent = 0
  .RightIndent = 0
  .SpaceBefore = 0
  .SpaceAfter = 0
  .LineSpacingRule = wdLineSpaceSingle
End With
End Sub  
如果您对Applescript更为熟悉,则其等效项如下所示:

-- you may need to fix up the application name
-- (I use this to ensure that the script uses the Open Word 2011 doc
-- and does not try to start Word for Mac 15 (2016))
tell application "/Applications/Microsoft Office 2011/Microsoft Word.app"
    tell the paragraph format of the text object of table 1 of the text object of the selection
        set paragraph format left indent to 0
        set paragraph format right indent to 0
        set space before to 0
        set space after to 0
        set line spacing rule to line space single
    end tell
end tell

除了WinWord,我对这个问题的任何内容都不熟悉,但是。。。能否以字符分隔格式输出表格数据?作为文件还是字符串?如果是,则可以在文档中插入/写入,并使用Word对象模型的ConvertToTable方法将其转换为表。。。能否以字符分隔格式输出表格数据?作为文件还是字符串?如果是,则可以在文档中插入/写入,并使用Word对象模型的ConvertToTable方法将其转换为表。