一、Aspose.Words 如何获取word每个段落的编号 或者项目符号
工具/原料
电脑装有Word2007软件
方法/步骤
1.加基本的项目符号
方法:选择多个段落,从“开始”菜单——段落中的项目符号,单击后面的倒三角,选择已有的符号单击即可
2.定义新项目符号
方法:选择多个段落,从“开始”菜单——段落中的项目符号,单击后面的倒三角,选择“定义新项目符号”,会打开“定义新项目符号”对话框
3.选择不同的符号
方法:选择多个段落,从“开始”菜单——段落中的项目符号,单击后面的倒三角,选择“定义新项目符号”,会打开“定义新项目符号”对话框,单击“符号”按钮,可以选择不同的符号
4.选择图片作符号
方法:选择多个段落,从“开始”菜单——段落中的项目符号,单击后面的倒三角,选择“定义新项目符号”,会打开“定义新项目符号”对话框,单击“图片”按钮,可以从电脑上选择不同的图片做符号
5.可以给符号设置颜色
方法:选择多个段落,从“开始”菜单——段落中的项目符号,单击后面的倒三角,选择“定义新项目符号”,会打开“定义新项目符号”对话框,单击“字体”按钮,打开“字体”对话框,选择字体颜色,单击确定
步骤阅读
https://jingyan.baidu.com/article/1876c85287119f890b137635.html
二、aspose.word 怎么把word里的章节分别取出来
Document doc = new Document(attchmentPath);
string str=doc.GetText();
只知道保存html 或pdf时能把图片导出来。。。
private string ReadWord(string path)
{
Document doc = new Document(path);
using (MemoryStream ms = new MemoryStream())
{
doc.SaveOptions.HtmlExportImagesFolder= "temp/"; //debug下建个temp目录用于存图片。
doc.Save(ms, SaveFormat.Html);
string text = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
return text;
}
}
三、怎么用python将word转成html
#coding=utf-8
#文件名:
#BatchConverWords2Html.py
#说明:
#批量将一个文件夹下的所有.doc/.docx文件转为.html文件,需要安装对应的win32模块
#调用方式:进入源程序目录,命令:python BatchConverWords2Html.py RootDir
from win32com import client as wc
import os
word = wc.Dispatch('Word.Application')
def wordsToHtml(dir):
for path, subdirs, files in os.walk(dir):
for wordFile in files:
wordFullName = os.path.join(path, wordFile)
#print "word:" + wordFullName
doc = word.Documents.Open(wordFullName)
wordFile2 = unicode(wordFile, "gbk")
dotIndex = wordFile2.rfind(".")
if(dotIndex == -1):
print "********************ERROR: 未取得后缀名!"
fileSuffix = wordFile2[(dotIndex + 1) : ]
if(fileSuffix == "doc" or fileSuffix == "docx"):
fileName = wordFile2[ : dotIndex]
htmlName = fileName + ".html"
htmlFullName = os.path.join(unicode(path, "gbk"), htmlName)
#htmlFullName = unicode(path, "gbk") + "\\" + htmlName
print "generate html:" + htmlFullName
doc.SaveAs(htmlFullName, 10)
doc.Close()
word.Quit()
print ""
print "Finished!"
if __name__ == '__main__':
import sys
if len(sys.argv) != 2:
print "Usage: python funcName.py rootdir"
sys.exit(100)
wordsToHtml(sys.argv[1])运行结果就是在rootdir目录下的所有word文档转为简洁版的html网页文件,生成的文件存在原word同目录下,生成 xxx.files 文件夹。
四、aspose.word 表格在第二页怎么用movetocell
可以使用书签。
首先你要在创建一个word 然后添加一个table的书签 private static void SetTargetTable(Document doc, List targetList) { if (doc.Range.Bookmarks["table"] != null) { if (targetList.Count == 0) { doc.Range.Bookmarks["table"].Text = "无邀约客户"; } else { DocumentBuilder builder = new DocumentBuilder(doc);//Get cells' width double[] widths = new double[4]; for (int i = 0; i < 4;="" i++)="" {="" builder.movetocell(0,="" 0,="" i,="" 0);="" widths[i]="builder.CellFormat.Width;" }//fill="" cells="" builder.movetobookmark("table");="" for="" (int="" i="0;" i="">< targetlist.count;="" i++)="" {="" setcell(builder,="" widths[0],="" (i="" +="" 1).tostring());="" setcell(builder,="" widths[1],="" targetlist[i].name);="" setcell(builder,="" widths[2],="" targetlist[i].phone);="" setcell(builder,="" widths[3],="" targetlist[i].salesman);="" builder.endrow();="" }="" doc.range.bookmarks["table"].text="string.Empty;" }="" }="" }="" private="" static="" void="" setadplandetailtable(document="" doc,="" list="" detaillist)="" {="" if="" (doc.range.bookmarks["table"]="" !="null)" {="" if="" (detaillist.count="=" 0)="" {="" doc.range.bookmarks["table"].text="无详细广告计划" ;="" }="" else="" {="" documentbuilder="" builder="new" documentbuilder(doc);//get="" cells'="" width="" double[]="" widths="new" double[7];="" for="" (int="" i="0;" i="">< 7;="" i++)="" {="" builder.movetocell(0,="" 0,="" i,="" 0);="" widths[i]="builder.CellFormat.Width;" }//fill="" cells="" builder.movetobookmark("table");="" for="" (int="" i="0;" i="">< detaillist.count;="" i++)="" {="" setcell(builder,="" widths[0],="" (i="" +="" 1).tostring());="" setcell(builder,="" widths[1],="" detaillist[i].name);="" setcell(builder,="" widths[2],="" detaillist[i].amount);="" setcell(builder,="" widths[3],="" detaillist[i].unit);="" setcell(builder,="" widths[4],="" detaillist[i].unitprice);="" setcell(builder,="" widths[5],="" detaillist[i].totalprice);="" setcell(builder,="" widths[6],="" detaillist[i].time);="" builder.endrow();="" }="" doc.range.bookmarks["table"].text="string.Empty;" }="" }="" }="" private="" static="" void="" setcell(documentbuilder="" builder,="" double="" width,="" string="" value)="" {="" builder.insertcell();="" builder.cellformat.borders.color="System.Drawing.Color.Black;" builder.cellformat.borders.linestyle="LineStyle.Single;" builder.cellformat.width="width;" builder.cellformat.verticalmerge="Aspose.Words.Tables.CellMerge.None;" builder.write(value);="">
转载请注明出处51数据库 » asposewordtohtml