You are viewing limited content. For full access, please sign in.

Question

Question

Reading from Excel file

SDK
asked on January 19, 2017

Hi

I'm trying to read from excel file.

The problem that I have I think is related to the version of excel. I use 2016. When I drop the excel file to the Laserfiche client my script will pick it up from there and place it on the C drive as well as saving the path as a token. I also have a second script to read from this file but every single time I try to run it I got the message that workflow couldn't find the required file. It seems to me that is something related to naming convention. I checked the version of Excel 2013 and when it is saving to the folder (first script) I can see that file looks like 'test.xlsx'  but when I use newest version the name shows 'test' only. So I assuming that's why my workflow can't find it.

First script:

   string filePath = "C:\\Connectivity\\TEST."  + DI.Extension.ToString();

 

Second script:

string filePath = GetTokenValue("FilePath").ToString();

 

Anybody had that problem before?

Any help will be much appreciate.

0 0

Replies

replied on August 13, 2020

The way that I normally read from an Excel file with workflow is to always export it to the same location with the same name.  I then create an ODBC System DSN (make sure to use 64 bit ODBC if WF Server is 64 bit) that points to that file and use a query data activity to extract what I need.

2 0
replied on August 13, 2020

Hi Bert Warren,

I am new to that. Can you please explain me how to do that ?  

I have tried as per your suggestion. 

Below is my code and i'm getting "The requested collection (EXP_Purchase_OrderNEW) is not defined" (Error screenshot attached).

Note: EXP_Purchase_OrderNEW is the sheet name

-------------------Code-----------------------------

 List<string> tableList = new List<string>();
            string excelFile = @"C:\Temp\2.xlsx";
            string excelCS = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFile + ";" +
                                         "Extended Properties=\"Excel 12.0 Xml;HDR=YES\"";

            using (OleDbConnection connection = new OleDbConnection(excelCS))
            {
                connection.Open();
                DataTable tableInfo = connection.GetSchema("EXP_Purchase_OrderNEW");
                foreach (DataRow row in tableInfo.Rows)
                {
                    tableList.Add(row["Node Name"].ToString());
                }
                connection.Close();
            }

 

Please help me with this. 

 

Thanks a lot,

Rajah

 

 

 

Error.PNG
Error.PNG (5.01 KB)
0 0
replied on August 13, 2020

You only want your SDK Script activity to export the Excel document to a defined folder with a defined name (example, always export as C:\Temp\Source.xlsx).  Once the document is exported, then use a Query Data activity to query it.  Finally, I also use a Script activity to delete the source Excel document.

Below is the basics of this workflow:

0 0
replied on January 19, 2017

Is the Workflow server on the same machine as the folder you're exporting to?

0 0
replied on January 19, 2017

Yes it is.

0 0
replied on January 19, 2017

First script:

 

 DocumentInfo DI = Document.GetDocumentInfo(this.BoundEntryId, this.RASession);
                DocumentExporter DE = new DocumentExporter();
                string filePath = "C:\\Connectivity\\TEST."  + DI.Extension.ToString();
                DE.ExportElecDoc(DI, filePath);
                WorkflowApi.SetTokenValue("FilePath", filePath);

Error:

 

0 0
replied on January 19, 2017

Oh, you're trying to use Excel in your workflow script? That's unlikely to work since there is no user session to launch Excel in.

0 0
replied on January 19, 2017

The previous version was working fine without any problems at all. This change the way excel saves files causing me troubles...

Yes, this is SDK in workflow.

0 0
replied on August 13, 2020

hi Lukasz Jankowski,

I am working on the same requirement. I too get the same error. Did you get any resolution for this ? 

 

Please share, it will be very helpful. 

 

Thank you 

Rajah

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.