You are here:   Blogs
Register   |  Login

News & Releases

Minimize
Nasosoft Component for .NET v2.8 Released - Wednesday, July 28, 2010

Nasosoft Component for .NET v2.8 has released with many improvements.

Nasosoft Component for .NET is a suite of comprehensive .NET controls, including EXCEL, PDF, and RTF document format engines, RTF to HTML, HTML to RTF, RTF to TEXT, HTML to TEXT document transform engines, Chart control, SMTP, POP3, IMAP, FTP, WebDAV internet SDK and ZIP, GZIP, TAR compression.

What's new

  • Nasosoft Excel 
    • Support reading Excel 95 file format  
    • Improved error recovery for loading unreadable excel files
  • Nasosoft Transform
    • Support Text to PDF convertion 
  • Nasosoft PDF
    • Support MeasueString
  • Many Bug fixes from v2.7

How to Download

 

How to use Nasosoft Excel in C++/COM

Minimize
Location: Blogs.NET Programming    
Posted by: host 5/13/2010 7:39 AM

Nasosoft Excel provides COM+ interfaces for C++/COM interop. You can use these API in your C++ applications to manage Excel documents, without Microsoft Office installed on your servers.

Step 1:

Register Nasosoft.Documents.Xls.dll with Regasm.exe.  Run:

Regasm.exe Nasosoft.Documents.Xls.dll

Step 2:

Refer the Nasosoft.Documents.Xls.tlb file in your C++ project

Step 3:

Initialize COM+, and get a pointer to IXlsDocumentBuilder instance

::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 IXlsDocumentBuilderPtr comObj(__uuidof(XlsDocumentBuilder));

Step 4:

Dispose the instance and Uninitialize COM+.

Code:

#include "stdafx.h"
#include
#include
#include
#include
#import "mscorlib.tlb"
#import "System.Drawing.tlb"
#import "D:\\nasosoft\\private\\Runtime\\public\\Net 2.0\\Nasosoft.Documents.Xls.tlb" no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
 
 ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
 IXlsDocumentBuilderPtr comObj(__uuidof(XlsDocumentBuilder));
 
 if(comObj)
 {
  comObj->SetLicense(L"D:\\nasosoft\\license\\Nasosoft.All.lic");
  IXlsWorkbookPtr workbook= comObj->Create();
  IXlsWorksheetCollectionPtr worksheets = workbook->GetWorksheets();
  IXlsWorksheetPtr worksheet = worksheets->GetItem_2(0);
  
  _bstr_t s = worksheet->GetText(1, 1);
  worksheet->SetText(1, 2, L"hello cpp interop!");
  
  workbook->Save_2(L"d:\\hello3.xls");
  
  workbook->Release();
  comObj.Release();
 }

 ::CoUninitialize();
 return 0;
}

Permalink |  Trackback