Resolved Trying to use an home C# Class

OS: Windows Server 2012 R2
Progress: 10.2B.08

Hello guyz,


So I recently tried to enhanced our program that generate excel file.
Current version:
1. Generate csv file
2. Launch excel by progress
3. Open the csv file
4. Saving it as an xlsx file.
Our main issue with this version is for text value. If the value is starting by 0 like this 00045600 (a product ref by example) excel will prompt 45600 .

So by brosing forum and willing to do that I do by hand I choose to use the opentextfile method of excel directly in progress like this:
Code:
DEFINE VARIABLE myFieldFormat AS INTEGER EXTENT 4     NO-UNDO.

excelAppl:Workbooks:OpenText(toto,
                             ,
                             ,
                             {&xlDelimited},
                             {&xlTextQualifierDoubleQuote},
                             FALSE,
                             FALSE,
                             TRUE,
                             FALSE,
                             FALSE,
                             FALSE,
                             ,
                             myFieldFormat,
                             ,
                             ,
                             ,
                             ,
                             TRUE) .

The main issue there is that excel expect an array of array. And I didn't found a way to do it.

So if it works in .NET why not doing with .NET code called by a progress procedure.

I did create one that I would like to test
C#:
using System;
using Excel = Microsoft.Office.Interop.Excel; // Will need Excel fonctionnality

namespace OpenTxtFileExcel; // Name space of the class


public class OpenTextFileExcel // Class
{
    public string myTxtFile; // path of the input TXT file
    public string myExcelFile; // path of the output xlsx file
    public string fieldFormat; // data format field list to be translate in an array of array

    public void Open()
    {
        Excel.Application myExcel = new Excel.Application()  ; // initiate excel
        if (myExcel != null) // If excel is running then go
        {
            // Create the workbook
            Excel.Workbooks myWB = myExcel.Workbooks ;
            // Open the text file
            myWB.OpenText(myTxtFile,,xlDelimited,xlTextQualifierDoubleQuote,,,TRUE,,,,,,,,,,TRUE) ;
            // Saving it as xlsx file
            myWB.SaveAs(myExcelFile,51,,,,,,2);
           

        }
    }
}

But now I don't find a way to use it in my progress procedure:
Code:
DEFINE VARIABLE maClass AS CLASS OpenTextFile .
Progress is telling me that he can't found the interface or class corresponding to it. I believe it because I don't how to tell him where to found it.

So my questions are as folow:
1. Is there another way of doing it
2. How can I use homemade Class (C# or Progress) with the appbuilder

Best Regards and thanks in advance
 

Attachments

  • OpenTextFileExcel.zip
    583 bytes · Views: 1

Cringer

ProgressTalk.com Moderator
Staff member
"Simply" upgrade to a modern and supported version of Progress and you will find that you will be able to use .Net in OpenEdge. I know that's not particularly helpful, but why reinvent the wheel?
 

Osborne

Active Member
I do not know if this relevant but I seem to recall reading that the OpenText method did not always work if the file had an extension of csv and changing to txt solved.

Regarding the array, again I seem to recall this had to be an extent of 2 only but not sure. If you change to this does that solve?:
Code:
DEFINE VARIABLE myFieldFormat AS INTEGER EXTENT 2     NO-UNDO.

myFieldFormat[1] = 0.
myFieldFormat[2] = 2.

Finally, as Cringer posted you can use .NET and I think this may be possible for your version of Progress. Instead of creating a C# cs file create a C# .NET dll and add using Progress assemblies.
 
@Cringer I'm in project on upgrading to a newer version . We are targeting 11.7 (Limited by our ERP provider) .
The array doesn't work when I'm trying to use it.
I come up also with the idea of a powershell script.
But as @Cringer said a newer version could help me, I will try with a 11.7 that I have and hope that I can upgrade the other asap.
Best Regards and thank you for your help
 
Top