How to get data from Excel Sheet

hai all,

       Is it possible to read a Microsoft Excel file using webMethods? If so, how? , i am using webMethods 6.1 

Thanks in advance,
syam

Syam,

There are few threads discussed on the similar query,please use the keyword search “excel” in this site,you should get some useful results.

what is your excel file extension .xls or .csv?If it is .csv using WmFlatFile Adapter in IS6.x will allow you to parse based on the flatfile csv schema that you have to create.Please see the ISFlatFileSchemaUserguide for more information how to create a flatfile Schema/Dictionaries

Also visit ItemField.com (partners of webMethods)specialists in handling Excel workbook files etc…

HTH,
RMG

Nope. As a company, webMethods can do lots of things but reading a Microsoft Excel file is not one of them–at least not in a way that’s useful for us. The company named webMethods has several products (such as webMethods Fabric, which is a suite with other products such as Integration Server and Broker), some of which can be used to read Excel files.

I’m not familiar with any product named “webMethods 6.1” (just like I haven’t heard of anything named “Microsoft 3.1” or “TIBCO 5.0” or “IBM 4.2”). webMethods is a company which sells many products, none of which are simply named “webMethods”. Some companies have a name that is shared with their primary product. webMethods is not one of them.

Strictly speaking, if the extension is .csv then it isn’t an Excel file per se (though Excel can read .csv files just fine).

:slight_smile: :slight_smile: :slight_smile:

Okay, I’m done being a smart aleck. For today anyway!

rmg is right that there are several posts about approaches for creating and reading Excel files using open source tools such as POI and the like. Let us know if those aren’t sufficient to get you headed in the right direction.

Step 1: Create a new workbook instance and get the first worksheet.

1
Workbook newBook = new Workbook();
2
Worksheet newSheet = newBook.Worksheets[0];
Step 2: Create a new workbook instance and load the sample excel file.

1
Workbook workbook = new Workbook();
2
workbook.LoadFromFile(“Information.xlsx”);
Step 3: Get the worksheet where you want to retrieve and extract data from. In this sample, it’s the first worksheet.

1
Worksheet sheet = workbook.Worksheets[0];
Step 4: Retrieve data and extract to the first worksheet of the new excel workbook.

01
int i = 1;
02
int columnCount = sheet.Columns.Count();
03
foreach (CellRange range in sheet.Columns[0])
04
{
05
if (range.Text == “teacher”)
06
{
07
CellRange sourceRange = sheet.Range[range.Row, 1, range.Row, columnCount];
08
CellRange destRange = newSheet.Range[i, 1, i, columnCount];
09
sheet.Copy(sourceRange, destRange, true);
10
i++;
11
}
12
}
Step 5: Save the target file as NewForm.xlsx.

I hope this helps!
Ben Martin
Apps4Rent