Installing ExcelWriter for .NetSoftArtisans ExcelWriter is currently available only as a traditional COM object and not as managed code. It is available for use in the .NET framework by means of "Interop." This has no performance or functionality implications, but it does make deployment a bit more complicated. When integrating ExcelWriter into your Visual Studio.NET solution, it will be necessary to first register SAExcel.dll on the server which will execute your code. This can be done by running the ExcelWriter auto-installation program on the server, or by registering the dll using regsvr32. You then have the option of installing the SAExcelDotNet.dll wrapper and the associated SAExcelRCW.dll as part of a single application, or for all applications running on the server (global installation). To integrate ExcelWriter into a single application that is not a Visual Studio.NET solution:
To make ExcelWriter globally available to .NET applications:
To incorporate ExcelWriter into a Visual Studio.NET project, add references to SAExcelDotNet.dll and SAExcelRCW.dll to your project as follows:
Page Settings
Using ExcelWriter with ADO.NETExcelWriter's principal objects are
ExcelApplication
and ExcelTemplate.
ExcelWriter Version 3 included the .NET wrappers
V4 In addition to
Example 1: ExcelWriter in an .aspx PageNote: Some ExcelWriter parameters are optional in a COM environment (such as ASP or Visual Basic) and are defined as optional in the Programmer's Reference. In .NET, all parameters must be present. <%@ Page language="C#" aspcompat=true %> <script runat=server> void Page_Load(object sender, EventArgs args) { SoftArtisans.ExcelWriter.SAExcelApplicationClass xlw = new SoftArtisans.ExcelWriter.SAExcelApplicationClass(); SoftArtisans.ExcelWriter.SAWorksheet sheet = xlw.Worksheets[1]; sheet.Cells[1, 1].Value = 20; xlw.Save(@"workbook.xls", SoftArtisans.ExcelWriter.SASaveMethod.saOpenInPlace, SoftArtisans.ExcelWriter.SAFileFormat.saFileFormatExcel2000); } </script> Example 2: ExcelWriter in Microsoft Visual C#.NETNote: Some ExcelWriter parameters are optional in a COM environment (such as ASP or Visual Basic) and are defined as optional in the Programmer's Reference. In .NET, all parameters must be present. using System; using SoftArtisans.ExcelWriter; namespace SoftArtisans.Samples { class ExcelWriterSamples { [STAThread] static void Main(string[] args) { SAExcelApplication xlw = new SAExcelApplication(); SAWorksheet sheet = xlw.Worksheets[1]; sheet.Cells[1, 1].Value = 20; xlw.Save(@"workbook.xls", SASaveMethod.saOpenInExcel, SAFileFormat.saFileFormatExcel2000); } } } Example 3: ExcelWriter in Microsoft VB.NETNote: Some ExcelWriter parameters are optional in a COM environment (such as ASP or Visual Basic) and are defined as optional in the Programmer's Reference. In .NET, all parameters must be present. Imports SoftArtisans.ExcelWriter Namespace SoftArtisans.Samples Public Class ExcelWriterSamples Example 4: Using ExcelTemplate in ASP.NET with Microsoft Visual C#.NETNote: Some ExcelWriter parameters are optional in a COM environment (such as ASP or Visual Basic) and are defined as optional in the Programmer's Reference. In .NET, all parameters must be present. <%@ Page language="C#" %> <%@ Import namespace="SoftArtisans.ExcelWriterDotNet" %> <script runat=server> void Page_Load(object sender, EventArgs args) { SAExcelTemplateClass xlw = new SAExcelTemplateClass(); xlw.Open (Server.MapPath("Template.xls")); object [,] arDoors = { {"Morrison", "Jim"}, {"Manzarek", "Ray"}, {"Krieger", "Robby"}, {"Densmore", "John"} }; xlw.set_Datasource("Doors", 65536, arDoors); xlw.Process("TheDoors.xls", SAProcessMethod.saProcessDefault, 1); System.Runtime.InteropServices.Marshal.ReleaseComObject(xlw);4 } </script> Example 5: Using ExcelTemplate in ASP.NET with Microsoft VB.NETNote: Some ExcelWriter parameters are optional in a COM environment (such as ASP or Visual Basic) and are defined as optional in the Programmer's Reference. In .NET, all parameters must be present. Imports SoftArtisans.ExcelWriter Namespace SoftArtisans.Samples Public Class ExcelWriterSamples
Copyright © 2003, SoftArtisans, Inc. |