Error in excel desktop wrapper

Pachuquin

Member
Licensed User
Longtime User
Error in excel desktop wrapper. SOLVED

Hi

Excuse my english.

I'm trying to write a wrapper to read/write excel files.

It works fine when it runs from the IDE and I can compile it without optimized compilation, but it doesn't work in optimized compilation.

Help, please.


Forget it. I got to solve it. I only had to add the Microsoft.Office.Interop.Excel.dll library to the IDE.
 

Attachments

  • Microsoft.Office.Interop.Excel.zip
    303.3 KB · Views: 252
  • pachExcelNet.zip
    103.3 KB · Views: 253
Last edited:

timsteeman

Member
Licensed User
Longtime User
Your English is as good as mine...

but your solution to connect to Excel is very good!
I have 1 question; reading gives an empty string
example:
excel.ActivateSheet("Sheet1")
x=excel.ReadCell(1,1)
excel.CloseWorkBook(True)
Form1.Show
Msgbox(x)

The messagebox is empty. Do i make a mistake?

Tim
 

Pachuquin

Member
Licensed User
Longtime User
You are right.

I have updated it and it should work fine now, but it throws an exception when the cell is empty because I have just started to write it.

Now, I have a problem.

I have to add the Microsoft.Office.Interop.Excel.dll library to the IDE to get that the optimized compilation works. But this library contain hundreds of objects and I can't add libraries like ControlEx, because both libraries contains objects with the same name (ex: Toolbar).
I could modify the source code of ControlEx to rename the class Toolbar, but if I only had the dlls, how could I solve it?

Thanks
 
Last edited:

agraham

Expert
Licensed User
Longtime User
if I only had the dlls, how could I solve it?
Use an intermediate library to access the one that accesses Excel via the interop library and only expose/rename the functionality that you want. Add only the intermediate library to Basic4ppc, not the Excel access one.
 

Cableguy

Expert
Licensed User
Longtime User
@Pachuquin

This is a very usefull dll.
Please, when you are satisfied with your work, and find the solution to be usable and stable enought, PM me so I can list it.
 

Pachuquin

Member
Licensed User
Longtime User
That's what I am trying to do, but if you try the example you get an error when trying to compile it in optimized compilation. You have to add the Microsoft.Office.Interop.Excel.dll library (which have hundreds of objects) to avoid the error.
 

Cableguy

Expert
Licensed User
Longtime User
with a wrapper, as Andrew suggested, you only expose to b4ppc the props and objects you choose to...
This means that, you may have to "create" a more complex dll, with all the interops, and the create a wrapper to it so it can work under 4ppc... look at this example I starde with a 2 files "native" dlls and build a wrapper to them.
That simplifies the process, and since this would be a desktop only (?) dll, the dll size is of no big importance.
 

agraham

Expert
Licensed User
Longtime User
I've looked at your app. You should not need to add the Interop library as a component just pachexcellnet.dll. It will compile and work ok. However if you are trying to merge your library using pachExcelNet.cs in the Libraries folder then you need to add a reference to the interop library in your source.

To merge you should have the version of the library as the first line. The compiler reports this version after compilation. Note the space after the colon.

//version: x.y


To reference the Interop library add a second line comment like this with the correct path\filename. This library will be referenced during compilation and it will also be copied to the project folder. Note the space after the colon. The path is relative to the Library folder so if you put the Interop library there with your source you will only need to include the filename

//ref: pathtoInteropLib\Microsoft.Office.Interop.Excel.dll
 

timsteeman

Member
Licensed User
Longtime User
A very good dll

Dear Pachuquin,
I told you in my first post.... you have made a very nice wrapper.
I like it so much that i took the time starting to understand "how to make a library".

It is your library, so i want to ask you to have a look at "my extension". Do you like it? Or is it a little overkill?

But once again.... a very nice and useable wrapper!


public void WriteCell(int Col, int Row, string Value, bool IsText, bool Italian, bool Bold, bool Colourcell)
{
[/INDENT]_ExcelRng = (Excel.Range)_ExcelSheet.Cells[Row, Col];
if (IsText)
{
_ExcelRng.NumberFormat = "@";
}
else
{
_ExcelRng.NumberFormat = "#.##0,00;[Rood]-#.##0,00";
}
if (Italian)
{
_ExcelRng.Cells.Font.Italic = true;
}
else
{
_ExcelRng.Cells.Font.Italic = false;
}
if (Bold)
{
_ExcelRng.Cells.Font.Bold = true;
}
else
{
_ExcelRng.Cells.Font.Bold = false;
}
if (Colourcell)
{
_ExcelRng.Interior.ColorIndex = 34;
}
else
{
_ExcelRng.Interior.ColorIndex = 0;
}
_ExcelSheet.Cells[Row, Col] = Value;
}
 
Last edited:

Pachuquin

Member
Licensed User
Longtime User
Thanks Tim.

All improvements to the the library are welcome, but this is only a starting point.This one isn't the way that I want to do it. I want to create several objects: Workbook, Sheet, Cell, Fileformat,etc... to make a more usefull library.
 
Top