xlsgen > overview > Source code generator

The source code generation tool that ships with xlsgen reverse engineers an arbitrary Excel spreadsheet, and outputs the equivalent :

source code required to generate that Excel spreadsheet.

Code generation is a big time saver, in that you don't have to learn the xlsgen object model to program with xlsgen.

The automatic source code generation tool generates the corresponding source code for most Excel features :

 

What does the source code generator look like?

As part of the xlsgen install is the source code generator. Start it from the Windows programs menu, clicking on the shortcut xlsgen / source code generator.


code generator produces xlsgen-compliant code in VB, VBScript, C#, C++, Java, Python and Powershell

 

How to use it?

The source code generator is both a little executable installed along with xlsgen, as well as an interface method available from xlsgen itself. The little executable can be found in the xlsgen application directory, under the name xlscodegen.exe.


source code generator produces xlsgen-compliant code in VB, VBScript, VB.NET, C#, C++ Java and Python

Use the browse button to browse for an existing Excel workbook. The code for it is automatically generated using the current language selected in the combo-box, on the right. The default programming language target is Visual Basic.


source code generator produces xlsgen-compliant code in VB, VBScript, VB.NET, C#, C++ Java Python and Powershell

By default, any formula statement in the generated code will use English as the default Formula language. You can choose French alternatively (or German, Spanish, Italian and Portuguese) thanks to the other dropdown control.


source code generator produces xlsgen-compliant code in VB, VBScript, VB.NET, C#, C++ Java Python and Powershell

The code for the Excel workbook is dumped in the main window. You can copy it in the clipboard using the button on the top right corner. Once in the clipboard, you can paste the code in your code editor and create a xlsgen-powered Excel workbook without being seen!

You can get output for cells in Html format (programming the formatting of cells is expressed using an Html extended format), or regular object method calls.


code generator produces xlsgen-compliant code in VB, VBScript, VB.NET, C#, C++ Java Python and Powershell

If you have a preference for local files, just make sure the Generate a file checkbox is checked. A message box will notify you the exact filename.


code generator produces xlsgen-compliant code in VB, VBScript, VB.NET, C#, C++ Java Python and Powershell

 

Running the code generator programmatically

xlsgen exposes the interface to generate code using code. Here is how to use it with Visual Basic :

VB code

Dim engine As CoXlsEngine
Set engine = CreateObject("ExcelGenerator.ARsTDesign")

'
' read Book1_condform.xls and generate C++ code to create it
'
engine.GenerateCode("c:\tmp\Book1_condform.xls", "output.txt", gencode_cplusplus, formulalanguage_en, False, False)

Set engine = Nothing

For more information on options you can use, please take a look here.

 

Known limitations

The source code generation tool does not currently produce code for the following Excel objects :

 

xlsgen documentation. © ARsT Design all rights reserved.