3. Example C# - convert one file:
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
u.ConvertFile(@"d:\text.doc", @"d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML);
3.1. Example C# - convert collection of files:
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
string docFolder = @"d:\doc\";
string htmlFolder = @"d:\html\";
string[] files = Directory.GetFiles(docFolder, "*.doc");
//load MS Office in memory
int office = u.InitOffice();
//0 - loading OK
//1 - can't load MS Excel (Word and PowePoint OK)
//10 - can't load MS Word (Excel and PowerPoint OK)
//11 - can't load MS Word and Excel (PowerPoint OK)
//100 - can't load MS PowerPoint (Excel and Word OK)
//101 - can't load MS Excel and PowerPoint (Word OK)
//110 - can't load PowerPoint and Word (Excel OK)
//111 - can't load MS Office
if (office==0 || office==100 || office==101)
{
}
else
{
//MS Office isn't installed
return;
}
for (int i=0; i<files.Length; i++)
{
string htmlName = Path.Combine(htmlFolder,Path.GetFileNameWithoutExtension(files[i])+".htm");
u.ConvertFile(files[i], @"d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML);
}
u.CloseOffice();
|