![]() |
UseOffice
.Net - Robust .Net component to convert between Text, RTF, DOC, DOCX, HTML, XHTML, XLS, XLSX, CSV, PPT and PDF documents. version 2.02 (June 1st, 2009) |
| Help Content | About UseOffice .Net | Methods and properties | Samples of using in C#, VB.Net, ASP.Net | License | Pricing | Support and Contacts | |
The component can convert between DOC, DOCX, XLS, PPT, CSV, RTF, Text and
HTML formats with tables, images, fonts, colors etc.
int ConvertFile(string inputFile, string outputFile, eDirection convertingDirection) return values: SautinSoft.UseOffice u = new SautinSoft.UseOffice(); u.ConvertFile(@"d:\text.doc", @"d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML); Example VB: Dim u As New SautinSoft.UseOffice() To work our component UseOffice .Net requires MS Office installed. When you want to convert collection of documents at once we recomend you use also methods InitOffice(), InitWord() and InitExcel() togther with ConvertFile(). But if will skip the method InitOffice() so the ConvertFile() will work anyway. 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();
Example VB - convert collection of files: Dim u As New SautinSoft.UseOffice() Dim docFolder As String = "d:\doc\" Dim htmlFolder As String = "d:\html\" Dim files() As String = Directory.GetFiles(docFolder, "*.doc") 'load MS Office in memory Dim office As Integer = 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 OrElse office=100 OrElse office=101 Then Else 'MS Office isn't installed Return End If For i As Integer = 0 To files.Length - 1 Dim htmlName As String = Path.Combine(htmlFolder,Path.GetFileNameWithoutExtension(files(i)) & ".htm") u.ConvertFile(files(i), "d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML) Next i u.CloseOffice() int InitOffice()
int InitWord()
int InitExcel() loads MS Office®, MS Word®, MS Excel® library in memory. Example C#: SautinSoft.UseOffice u = new SautinSoft.UseOffice();
string[] docFiles = new string[] {@"d:\1.doc",@"d:\2.doc",@"d:\3.doc"};
string[] rtfFiles = new string[] {@"d:\1.rtf",@"d:\2.rtf",@"d:\3.rtf"};
//load MS Word in memory
int word = u.InitWord();
if (word!=0)
{
//MS Word inn't installed
return;
}
for (int i=0; i<docFiles.Length; i++)
{
u.ConvertFile(docFiles[i], rtfFiles[i], SautinSoft.UseOffice.eDirection.DOC_to_RTF);
}
u.CloseWord();
Example VB: Dim u As New SautinSoft.UseOffice()
Dim docFiles() As String = {"d:\1.doc","d:\2.doc","d:\3.doc"}
Dim rtfFiles() As String = {"d:\1.rtf","d:\2.rtf","d:\3.rtf"}
'load MS Word in memory
Dim word As Integer = u.InitWord()
If word<>0 Then
'MS Word inn't installed
Return
End If
For i As Integer = 0 To docFiles.Length - 1
u.ConvertFile(docFiles(i), rtfFiles(i), SautinSoft.UseOffice.eDirection.DOC_to_RTF)
Next i
u.CloseWord()
void CloseOffice() - releases MS Office® library from memory. void KillProcesses(string procName) - terminates process by its name. Beware: this function kill all processes with specified name. If Word, Excel or PowerPoint processes are still in memory you can use this function to terminate them. Example C#: u.KillProcesses("WINWORD");
u.KillProcesses("EXCEL");
u.KillProcesses("POWERPNT");
Example VB: u.KillProcesses("WINWORD")
u.KillProcesses("EXCEL")
u.KillProcesses("POWERPNT")
SautinSoft.UseOffice.eDirection - enum which allows you to specify converting directions:
Serial - your individual serial number to activate your product copy Example VB: u.Serial = "XXXXXXXXX" |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| © Copyright SautinSoft™ 2002 - 2009 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||