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


UseOffice .Net - methods and properties description

The component can convert between DOC, DOCX, XLS, PPT, CSV, RTF, Text and HTML formats with tables, images, fonts, colors etc.
This scheme shows all methods and properties of component:

Methods:

 ConvertFile()
 InitOffice()
 InitWord()
 InitExcel()
 CloseOffice()
 CloseWord()
 CloseExcel()
 KillProcesses()

 
Properties and settings:

converting parameters:


 eSautinSoft.UseOffice.eDirection
(about 40 converting directions)






license parameters:
 Serial (required in full version)
 

int ConvertFile(string inputFile, string outputFile, eDirection convertingDirection)

This methods converts a file (DOC, DOCX, RTF, XLS, HTML, Text, PPT) into another file (DOC, DOCX, RTF, XLS, HTML, Text, PPT, Webarchive, Text Unicode).
The variable 'convertingDirection' allows to specify converting direction. For example:
eDirection.HTML_to_DOC.

return values:

0 - converting OK
1 - can't open input file
2 - can't create output file
3 - converting Error
4 - MS Office isn't installed

Example C#
:

 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()
u.ConvertFile("d:\text.doc", "d:\text.html", SautinSoft.UseOffice.eDirection.DOC_to_HTML)

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.

return values:

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

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 CloseWord() - releases MS Word® library from memory.
void CloseExcel() - releases MS Excel® 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:

Value
From and To:
eDirection.DOC_to_HTML
DOC to HTML
eDirection.DOC_to_WEBARCHIVE
DOC to WEBARCHIVE
eDirection.DOC_to_XML
DOC to XML
eDirection.DOC_to_RTF
DOC to RTF
eDirection.DOC_to_TEXT
DOC to TEXT
eDirection.DOC_to_UNICODETEXT
DOC to UNICODE TEXT
eDirection.DOCX_to_HTML
DOCX to HTML
eDirection.DOCX_to_WEBARCHIVE
DOCX to WEBARCHIVE
eDirection.DOCX_to_XML
DOCX to XML
eDirection.DOCX to RTF
DOCX to RTF
eDirection.DOCX to TEXT
DOCX to TEXT
eDirection.DOCX_to_UNICODETEXT
DOCX to UNICODE TEXT
eDirection.HTML_to_DOC
HTML to DOC
eDirection.HTML_to_RTF
HTML to RTF
eDirection.HTML_to_TEXT
HTML to TEXT
eDirection.HTML_to_UNICODETEXT
HTML to UNICODE TEXT
eDirection.RTF_to_TEXT
RTF to TEXT
eDirection.RTF_to_UNICODETEXT
RTF to UNICODE TEXT
eDirection.RTF_to_HTML
RTF to HTML
eDirection.RTF_to_WEBARCHIVE
RTF to WEBARCHIVE
eDirection.RTF_to_XML
RTF to XML
eDirection.RTF_to_DOC
RTF to DOC
eDirection.XLS_to_RTF
(Excel) XLS to RTF
eDirection.XLS_to_HTML
XLS to HTML
eDirection.XLS_to_WEBARCHIVE
XLS to WEBARCHIVE
eDirection.XLS_to_XML
XLS to XML
eDirection.XLS_to_TEXT
XLS_to_TEXT
eDirection.XLS_to_CSV
XLS to CSV
eDirection.PPT_to_HTML
(PowerPoint) PPT to HTML
eDirection.PPT_to_WEBARCHIVE
PPT to WEBARCHIVE
eDirection.PPT_to_XML
PPT to XML
eDirection.PPT_to_RTF
PPT to RTF
eDirection.PPT_to_JPG
PPT to JPG
eDirection.PPT_to_BMP
PPT to BMP
eDirection.PPT_to_GIF
PPT to GIF
eDirection.PPT to DOC
PPT to DOC
eDirection.PPT_to_PDF
PPT to PDF

Serial - your individual serial number to activate your product copy

After purchasing you will get the full version of product and your serial number. This parameter doesn't have any effect in trial version. This parameter is necessary in full version, please don't forget to specify it by your serial number.

Possible values: any string
Default value: ""

Example C#:
u.Serial = "XXXXXXXXX";

Example VB: u.Serial = "XXXXXXXXX"

© Copyright SautinSoft™ 2002 - 2009