LEADTOOLS Forms (Leadtools.Forms.DocumentWriters assembly)
LEAD Technologies, Inc

XlsDocumentOptions Class

Example 





Members 
Provides extra options to use when saving a document using the Microsoft Excel 2003 format (XLS). .NET support
Object Model
XlsDocumentOptions Class
Syntax
public class XlsDocumentOptions : DocumentOptions 
'Declaration
 
Public Class XlsDocumentOptions 
   Inherits DocumentOptions
'Usage
 
Dim instance As XlsDocumentOptions
public sealed class XlsDocumentOptions : DocumentOptions 
function Leadtools.Forms.DocumentWriters.XlsDocumentOptions()
public ref class XlsDocumentOptions : public DocumentOptions 
Remarks

The options set in the XlsDocumentOptions class will be used when the user saves a document using the DocumentFormat.Xls format.

To change the options used with the XLS format, perform the following steps:

  1. Use the DocumentWriter.GetOptions method of the DocumentWriter object being used, passing DocumentFormat.Xls to the format parameter. Note the resulting object from the base DocumentOptions class needs to be cast to XlsDocumentOptions.
  2. Use the various XlsDocumentOptions properties to change the options.
  3. Use DocumentWriter.SetOptions to set the new options in the engine.
  4. Now call the DocumentWriter.BeginDocument method (with DocumentFormat.Xls for the format parameter) to create a new document and add the pages.

Currently, the XlsDocumentOptions class contains no extra options.

Example
 
' Windows API functions needed to load/delete an EMF
   <DllImport("gdi32.dll")> _
   Private Shared Function GetEnhMetaFile(ByVal lpszMetaFile As String) As IntPtr
   End Function
   <DllImport("gdi32.dll")> _
   Private Shared Function DeleteEnhMetaFile(ByVal hemf As IntPtr) As Boolean
   End Function

   Private Sub XlsDocumentOptionsExample()
      ' Unlock the support needed for LEADTOOLS Document Writers (with PDF output)
      RasterSupport.Unlock(RasterSupportType.DocumentWriters, "Replace with your own key here")

      ' Create a new instance of the LEADTOOLS Document Writer
      Dim docWriter As New DocumentWriter()

      Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Test.xls")
      Dim emfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf")

      Dim xlsOptions As XlsDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Xls), XlsDocumentOptions)

      docWriter.SetOptions(DocumentFormat.Xls, xlsOptions)

      ' Create a new XLS document
      Console.WriteLine("Creating new XLS document: {0}", outputFileName)
      docWriter.BeginDocument(outputFileName, DocumentFormat.Xls)

      ' Use the Windows API to load the EMF
      Dim emfHandle As IntPtr = GetEnhMetaFile(emfFileName)

      ' Add the page
      Dim page As DocumentPage = DocumentPage.Empty
      page.EmfHandle = emfHandle
      page.Image = Nothing

      Console.WriteLine("Adding EMF page from: {0}", emfFileName)
      docWriter.AddPage(page)

      ' Use the Windows API to delete the EMF
      DeleteEnhMetaFile(emfHandle)

      ' Finally finish writing the XLS file on disk
      docWriter.EndDocument()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
// Windows API functions needed to load/delete an EMF
   [DllImport("gdi32.dll")]
   private static extern IntPtr GetEnhMetaFile(string lpszMetaFile);
   [DllImport("gdi32.dll")]
   private static extern bool DeleteEnhMetaFile(IntPtr hemf);
   private void XlsDocumentOptionsExample()
   {
      // Create a new instance of the LEADTOOLS Document Writer
      DocumentWriter docWriter = new DocumentWriter();

      string outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Test.xls");
      string emfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.emf");

      XlsDocumentOptions xlsOptions = docWriter.GetOptions(DocumentFormat.Xls) as XlsDocumentOptions;

      // Use default resolution
      docWriter.SetOptions(DocumentFormat.Xls, xlsOptions);

      // Create a new XLS document
      Console.WriteLine("Creating new XLS document: {0}", outputFileName);
      docWriter.BeginDocument(outputFileName, DocumentFormat.Xls);

      // Use the Windows API to load the EMF
      IntPtr emfHandle = GetEnhMetaFile(emfFileName);

      // Add the page
      DocumentPage page = DocumentPage.Empty;
      page.EmfHandle = emfHandle;
      page.Image = null;

      Console.WriteLine("Adding EMF page from: {0}", emfFileName);
      docWriter.AddPage(page);

      // Use the Windows API to delete the EMF
      DeleteEnhMetaFile(emfHandle);

      // Finally finish writing the XLS file on disk
      docWriter.EndDocument();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

XlsDocumentOptions Members
Leadtools.Forms.DocumentWriters Namespace
DocumentWriter Class
Programming with LEADTOOLS Document Writers
Files to be Included with Your Application
Unlocking Special LEAD Features

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Forms.DocumentWriters requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features