DLL wrapper to umnanaged code

May 6, 2013 at 10:44 PM
Ouch... I am feeling as a total beginner in OOP (and I am!) - want to make a csharp dll on ClosedXML to export functions to unmanaged code:
    [DllExport("OpenFileXY", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    private static bool OpenFileXY(ref TNewFile par)
        XLWorkbook workbook = new XLWorkbook();
        return true;

    [DllExport("AddSheet", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    public static bool AddSheet(ref TNewSheet par)
        //Create a sheet - following line has an error message
        var worksheet = workbook.Worksheets.Add("Sample Sheet");
        ws.Cell("A1").Value = "Hello World!";
        return true;
Exporting works just fine but: how to proceed 'workbook' from method OpnenFileXY to AddSheet, so that the sheet will be opened in a 'workbook' created with OpenFileXY?

From unmanaged code there is a code such as this:

boolFld = OpenFileXY('FileName')
boolFld = AddSheet('SheetName1')
boolFld = AddSheet('SheetName2')
boolFld = WriteString2Cell('SheetName1', col, row, value)

Any help would appreciate...