ByteScout Spreadsheet SDK - C++ (unmanaged) - Hello World - ByteScout

ByteScout Spreadsheet SDK – C++ (unmanaged) – Hello World

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C++ (unmanaged) – Hello World

ByteScout Spreadsheet SDK – C++ (unmanaged) – Hello World


// IMPORTANT: Copy ByteScout.Spreadsheet.tlb into the project folder
// HelloWorld.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <windows.h>

#pragma warning (disable: 4278)

#import "c:\windows\system32\stdole2.tlb" rename_namespace("BytescoutSpreadsheet") exclude("GUID", "DISPPARAMS", "EXCEPINFO",  \

// To use managed-code servers like the C# server, 
// we have to import the common language runtime:
#import <mscorlib.tlb> raw_interfaces_only
#import <System.tlb> raw_interfaces_only
#import <System.Drawing.tlb> raw_interfaces_only

#import "Bytescout.Spreadsheet.tlb" rename_namespace("BytescoutSpreadsheet") //no_namespace named_guids 
int main(int argc, char* argv[])
	// initialize OLE
	HRESULT hr = CoInitialize(NULL);

	// check for errors
	if (FAILED(hr)) {
	MessageBox(0,"OLE initialization errp","error",MB_OK);
	return -1;
	// declare document object

	ISpreadsheet * Doc = NULL;
	CLSID clsid;
		_Worksheets* worksheets = NULL;
		_Worksheet* worksheet = NULL;
			_Cell* cell = NULL;

	// get inuque ID for ISpreadsheet interface
	hr = CLSIDFromProgID(OLESTR("Bytescout.Spreadsheet.Spreadsheet"), &clsid);
	// check for errors
	if (FAILED(hr)) {
	MessageBox(0,"Can't get CLSID for ISpreadsheet interface","error",MB_OK);
	goto Uninit;
	// create Spreadsheet object
	hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(ISpreadsheet), (LPVOID*)&Doc);
	// check for errors
	if (FAILED(hr)) {
	MessageBox(0,"Can't create Spreadsheet object","error",MB_OK);
	goto Uninit;

	//IWorksheets* worksheets = NULL;


	worksheet = reinterpret_cast<IWorksheets*>(worksheets)->Add("Sheet 1");

	cell = reinterpret_cast<IWorksheet*>(worksheet)->Cell("A1");

	reinterpret_cast<ICell*>(cell)->PutValueAsHTML("test value");

	// release PDFDoc object

	// uninitialize OLE libraries
	return 0;


// stdafx.cpp : source file that includes just the standard includes
//	HelloWorld.pch will be the pre-compiled header
//	stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file

  Click here to get your Free Trial version of the SDK