The Word adapter lets you modify the content of a Word document.
Syntax
public class Adapter : IDisposable
Members
bool SetDocumentBytes(byte[] data) |
Load document as binary data |
|
MemoryStream GetDocumentStream() |
Read document in binary data from memory |
|
bool ReplaceBookmark(string bookmarkName, string bookmarkText) |
Insert the specified text at the place of the given bookmark. (Replace placeholder text, if existing) |
|
bool ReplaceBookmarkKeepFormat(string bookmarkName, string bookmarkText) |
Insert the specified text at the place of the given bookmark while keeping the existing format |
|
bool ReplaceBookmark2(string name, string text, string formats) |
Insert the specified text at the place of the given bookmark. You may work with multiline text (e.g. the addressee) |
|
bool ReplaceBookmarkAsHyperlink(string name, string text, string url) |
Insert the specified text as a hyperlink at the place of the given bookmark |
|
bool FillBookmarkTable(string name, DataRows datarows, bool keepfirstrow = true) |
Insert the specified data table at the place of the given bookmark |
|
void Dispose() |
Releases the resources used |
Syntax
public class DataRows : List<DataRow>
Syntax
public class DataRow : List<DataColumn>
Members
DataFormat Format |
Row format |
Syntax
public class DataColumn
Members
string Content |
Content of the column |
|
DataColumnAlignment Align |
Alignment of the column content |
|
DataFormat Format |
Format of the column content |
Syntax
public enum DataFormat
Members
None = 0 |
Normal content |
|
Bold = 1 |
Content in bold |
|
Italic = 2 |
Content in italics |
|
UnderlineSingle = 4 |
Content with a single underline |
|
UnderlineDouble = 8 |
Content with a double underline |
Syntax
public enum DataColumnAlignment
Members
Left = 0 |
Content is left-justified |
|
Right = 1 |
Content is right-justified |
|
Center = 2 |
Content is centered |
|
Decimal = 3 |
Content is aligned with the decimal point |
Sample
This sample modifies the content of a Word document. The variable myfile points to a file which may either be uploaded from a web form or which could be retrieved out of a data store.
import clr
clr.AddReferenceToFileAndPath(Session.GetAdapterPath("IYOPRO.WORD"))
from IYOPRO.WORD import *
data = ProcessInstance.ReadFileBytes(myfile)
with Adapter() as word:
word.SetDocumentBytes(data)
word.ReplaceBookmark('MyBookMark','Hello World')
stream = word.GetDocumentStream()
ProcessInstance.WriteFileFromMemoryStream(myfile,stream)