我创建了一个带有一些数字和文本字段的单词模板,我从我的应用程序中导出了我的数据,如下所示:
dictionary of DataFrames
这是我将网格导出到另一个word文档的代码:
df = pd.concat([df1,df2, dfN], axis=1)
dfs = dict(tuple(df.groupby(df.columns.strftime('%Y-%m-%d'), axis=1)))
#select DataFrame
print (dfs['2015-03-13'])
如何使用它们并使用单词模板导出一个文档中的所有字段和网格?
答案 0 :(得分:0)
您必须遍历网格字段并使用aspose字段将它们插入到文档中:
Document wordDoc = new Document(myDoc);
foreach (GridViewRow row in GridView1.Rows)
{
foreach (Microsoft.Office.Interop.Word.Field myMergeField in wordDoc.Fields)
{
//iterate over fields and save to apose:
doc.MyField = row.MyRow;
}
}
//save To Aspose
Aspose必须知道您要填充的字段(如果有)。 否则,它不会输出任何东西。
此外,单词并不适用于网格。它不会让你导出表,因为它不能创建一个表,不像excel。 而不是插入整个网格,只需填充每个字段。