SOL9 Sample: XlsToHtmlApplet

SOL9 Samples

1 Screenshot


2 Source code

/*
 * XlsToHtmlApplet.cpp 
 * Copyright (c) 2009 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



// This is a sample program to convert a Excel file  to an Html file.

#include <sol/office/ExcelApplet.h>
#include <sol/office/ExcelWorkBook.h>

#include <sol/BString.h>


void _tmain(int argc, TCHAR** argv)
{
    if (argc !=2) {
        printf("Usage: XlsToHtmlApplet.exe XlsFullPathName\n");
        return;
    }

    try {
        
        BString docname = argv[1];
        ExcelApplet applet;
        
        try {
            ExcelWorkBook book = applet.open((BSTR)docname, false);
            printf("Opend an ExcelFile %S\n", (BSTR)docname);

            BString htmlFile = docname + ".html";
            _variant_t newfilename = (BSTR)htmlFile;

            _variant_t format = (short)Excel:: xlHtml;

            book.saveAs(newfilename, format);
            printf("Saved As %S\n", (BSTR)htmlFile);

            book.close();
            printf("Closed a document\n");
        } catch (HRESULT hr) {
            printf("Exception %x\n", hr);
        } catch (...) {
            printf("Unknown Exception \n");
        }

    } catch (HRESULT hr) {
        printf("Exception %x\n", hr);
    } catch (...) {
        printf("Unknown Exception \n");
    }
}


Last modified: 9 Apr 2010

Copyright (c) 2010 Antillia.com ALL RIGHTS RESERVED.