The implementation code is as follows:
Public class BiultReportForm
{
/// <SUMMARY> </SUMMARY>
/// Word Application Object
///
Private Microsoft. Office. Interop. Word. Application _ wordApplication;
/// <SUMMARY> </SUMMARY>
/// Word file object
///
Private Microsoft. Office. Interop. Word. Document _ wordDocument;
/// <SUMMARY> </SUMMARY>
/// Create a document
///
Public void CreateAWord ()
{
// Instantiate the word Application Object
This. _ wordApplication = new Microsoft. Office. Interop. Word. ApplicationClass ();
Object myNothing = System. Reflection. Missing. Value;
This. _ wordDocument = this. _ wordApplication. Documents. Add (ref myNothing, ref myNothing );
}
/// <SUMMARY> </SUMMARY>
/// Add a header
///
/// <PARAM name = "pPageHeader"/>
Public void SetPageHeader (string pPageHeader)
{
// Add a header
This. _ wordApplication. ActiveWindow. View. Type = Microsoft. Office. Interop. Word. WdViewType. wdOutlineView;
This. _ wordApplication. ActiveWindow. View. SeekView = Microsoft. Office. Interop. Word. WdSeekView. wdSeekPrimaryHeader;
This. _ wordApplication. ActiveWindow. ActivePane. Selection. InsertAfter (pPageHeader );
// Set the center alignment
This. _ wordApplication. Selection. ParagraphFormat. Alignment = Microsoft. Office. Interop. Word. WdParagraphAlignment. wdAlignParagraphCenter;
// Jump out of the header settings
This. _ wordApplication. ActiveWindow. View. SeekView = Microsoft. Office. Interop. Word. WdSeekView. wdSeekMainDocument;
}
/// <SUMMARY> </SUMMARY>
/// Insert text
///
/// <PARAM name = "pText"/> text information
/// <PARAM name = "pFontSize"/> small font size
/// <PARAM name = "pFontColor"/> font color
/// <PARAM name = "pFontBold"/> bold
/// <PARAM name = "ptextAlignment"/> direction
Public void InsertText (string pText, int pFontSize, Microsoft. Office. Interop. Word. WdColor pFontColor, int pFontBold, Microsoft. Office. Interop. Word. WdParagraphAlignment ptextAlignment)
{
// Set the font style and direction
This. _ wordApplication. Application. Selection. Font. Size = pFontSize;
This. _ wordApplication. Application. Selection. Font. Bold = pFontBold;
This. _ wordApplication. Application. Selection. Font. Color = pFontColor;
This. _ wordApplication. Application. Selection. ParagraphFormat. Alignment = ptextAlignment;
This. _ wordApplication. Application. Selection. TypeText (pText );
}
/// <SUMMARY> </SUMMARY>
/// Line feed
///
Public void NewLine ()
{
// Line feed
This. _ wordApplication. Application. Selection. TypeParagraph ();
}
/// <SUMMARY> </SUMMARY>
/// Insert an image
///
/// <PARAM name = "pPictureFileName"/>
Public void InsertPicture (string pPictureFileName)
{
Object myNothing = System. Reflection. Missing. Value;
// Center the image
This. _ wordApplication. Selection. ParagraphFormat. Alignment = Microsoft. Office. Interop. Word. WdParagraphAlignment. wdAlignParagraphCenter;
This. _ wordApplication. Application. Selection. InlineShapes. AddPicture (pPictureFileName, ref myNothing );
& N