5
Generated by Jive on 2014-08-14+02:00 1 Data extraction from multiple sheets of excel work book Business Requirement: I have a requirement where we will receive an excel workbook comprises of all cost center information (area wise) sheets in a single excel workbook. We should extract the data of all work sheets (CC1, CC2, and CC3) and load it in the target table. We recommended customer to create one more sheet by name SHEET_NAMES in the same workbook and list all the sheet names as shown below. Design I have used 1 WF & 2 DF, 2 script files (Start Script & EndScript) and 1 temporary table which stores sheet names information. First Dataflow: Will collects all the sheet names from excel workbook and stores in the Sheetnames table. 2 nd Dataflow in the workflow: Extracts the data from all the worksheets, maintaining work sheet names in the control table and assigning sheet names dynamically to global variable will be manipulated in StartScript and EndScript The Job comprises of 1. ExtractSheetNames_DF 2. CC_DATA_EXTRACT_WF 3. CC_DATA_EXTRACT_WF/CC_DATA_DF 4. Excel File Formats (CC_SheetNames and CC_DATA_INP) 5. Script Files (StartScript and EndScript) 6. Global Varaiable $GSheetName The prerequisites are

Reading Multiple Sheets of a Xls File in Bods

Embed Size (px)

DESCRIPTION

Reading Multiple Sheets of a Xls File in Bods

Citation preview

  • Generated by Jive on 2014-08-14+02:001

    Data extraction from multiple sheets of excelwork book

    Business Requirement: I have a requirement where we will receive an excel workbook comprises of all costcenter information (area wise) sheets in a single excel workbook. We should extract the data of all work sheets(CC1, CC2, and CC3) and load it in the target table.

    We recommended customer to create one more sheet by name SHEET_NAMES in the same workbook andlist all the sheet names as shown below.

    Design

    I have used 1 WF & 2 DF, 2 script files (Start Script & EndScript) and 1 temporary table which stores sheetnames information.First Dataflow: Will collects all the sheet names from excel workbook and stores in the Sheetnames table.2nd Dataflow in the workflow: Extracts the data from all the worksheets, maintaining work sheet names in thecontrol table and assigning sheet names dynamically to global variable will be manipulated in StartScript andEndScript

    The Job comprises of1. ExtractSheetNames_DF2. CC_DATA_EXTRACT_WF3. CC_DATA_EXTRACT_WF/CC_DATA_DF4. Excel File Formats (CC_SheetNames and CC_DATA_INP)5. Script Files (StartScript and EndScript)6. Global Varaiable $GSheetName

    The prerequisites are

  • Data extraction from multiple sheets of excel work book

    Generated by Jive on 2014-08-14+02:002

    1 DB Table with two columns SNo and Sheetnames During creation of CC_SheetNames excel file format in the Designer, mention Worksheet as

    SHEET_NAMES(contains all the sheet names) as specified below

    During creation of CC_DATA_INP excel file format in the Designer , mention the Worksheet withGlobal variable $GSheetName, the sheet name will be assigned dynamically in the Start Script.

  • Data extraction from multiple sheets of excel work book

    Generated by Jive on 2014-08-14+02:003

    Design StepsThe below diagram shows the overall job

    JOB_DynamicExcelExtraction

  • Data extraction from multiple sheets of excel work book

    Generated by Jive on 2014-08-14+02:004

    ExtractSheetNames_DF will collect all the sheet names from the work sheet SHEET_NAMES and stores it inSheetnames DB table

    In the below CC_DATA_EXTRACT_WF place while loop and put a condition that $GSheetName is not equalsto null.

  • Data extraction from multiple sheets of excel work book

    Generated by Jive on 2014-08-14+02:005

    1. In the StartScript, the first sheet name will be retrieved from Sheetnames table and will be assigneddynamically to the global variable.

    2. The CC_DATA_DF data flow will take the assigned sheet name from the global variable and extract theappropriate data

    3. In the EndScript, the assigned sheet name [from which the data is extracted in the step 2] will bedeleted from Sheetnames table

    While loop will execute the above 1,2,3 steps until the data extraction of all the sheets completed.

    Start Script codeprint(' Sheet Name is after delete in First Script'|| $GSheetName );$GSheetName = sql('Practice', 'select top 1 SHEET_NAMES from Sheetnames');print(' Sheet Name is after Selecting top 1 in First Script'|| $GSheetName );

    End Script codeprint(' Sheet Name is '|| $GSheetName );sql('Practice', 'delete from Sheetnames where SHEET_NAMES = {$GSheetName}' );print(' Sheet Name is after delete'|| $GSheetName );$GSheetName = sql('Practice', 'select top 1 SHEET_NAMES from Sheetnames');