mdb2xlsAPI example

We provide API which you can use from your own application to convert your data from one format to another.

You have to prepare an array with parameters and pass it to the StartConversion function. The list of parameters.

int StartConversion(string[] parameters);

returns 1 if there were not problems and conversion has started;
returns 0 if something is wrong with parameters. Additional info you can get in conversionDidFail.

void CancelConversion();

It allows you to break the conversion. API closes all opened files and stops.

delegate void ConversionDidFail(int code);

The function is called if there was some problem with input parameters:

  • 10 - Input or output files are not defined
  • 20 - Internal exception in the conversion cycle
  • 30 - Cannot open a source file
  • 40 - Cannot overwrite an output file
  • 50 - Cannot open an output file
  • 60 - Cannot save an output file

delegate void ConversionProgress(int percent);

This function provides information about the convertion progress. You can also cancel the process here by calling CancelConversion();

delegate void ConversionComplete(string[] outputFiles);

This function is called after conversion and returns a list of output files.


        private void button_Click(object sender, EventArgs e)
        {
            List<string> args = new List<string>();

            args.Add("d:\\source\\source.mdb");
            args.Add("-output=d:\\target\\target.xls");
            args.Add("-separate=0");
            //args.Add("-one more parameter");
            args.Add("-key=YOUR_REGISTRATION_CODE");

            mdb2xlsAPI dll = new mdb2xlsAPI();

            dll.conversionDidFail += new mdb2xlsAPI.ConversionDidFail(
                delegate(int code)
                {
                    MessageBox.Show("Return code " + code.ToString());
                }
            );

            dll.conversionProgress += new mdb2xlsAPI.ConversionProgress(
                delegate(int percent)
                {
                    progressBar1.Value = percent;
                    //if (condition)
                    //    dll.CancelConversion();
                }
            );

            dll.conversionComplete += new mdb2xlsAPI.ConversionComplete(
                delegate(string[] outputFiles)
                {
                    foreach (String s in outputFiles)
                    {
                        MessageBox.Show(s);
                    }
                }
            );

            dll.StartConversion(args.ToArray());
        }