Step for learning kettle in ExcelWriter

Source: Internet
Author: User
Tags excelwriter
The ExcelWriter step of kettle allows you to enter content in an excel template file and write content to different sheets of the same file. This article provides an example to illustrate how to generate a report through a conversion. ExcelWriter is available only in kettle4.1 and later versions. We also use Blockuntils.

The ExcelWriter step of kettle allows you to enter content in an excel template file and write content to different sheets of the same file. This article provides an example to illustrate how to generate a report through a conversion. ExcelWriter is available only in kettle4.1 and later versions. We also use Block until s.

Step for learning kettle in ExcelWriter

In the ExcelWriter step, you can enter content in an excel template file and write content to different sheets of the same file. This article provides an example to illustrate how to generate a report through a conversion.

The ExcelWriter step is available in kettle4.1 or later versions. We also use the "Block until steps finish" step (available in kettle4.1). If you use a version of 3.2 or 4.0, use the custom Objective C step instead. The sample code in this article is as follows:HereDownload.

Final export report file format

The example report file contains the Sales and expense information for six months. It contains three sheets: "Sales Chart" sheet, which contains a Chart showing the Sales status of each type each month.

"SourceData" sheet is the source data that needs to be filled in through kettle, including some fields, some calculated values and pie charts.

"Metadata" sheet is some information about the report itself. It is generated on the date of generation, the name of the conversion, and generated on that host.

Template File

In addition to the format of the template file, there is no data before the input. "SourceData" sheet needs to fill in the corresponding data. Other fields are automatically calculated (with formulas already available ).

"Metadata" sheet also needs to fill in some information.

Use kettle to fill in data in the template file

To analyze the Template File above, you need to enter the data entry point. There are four aspects to insert data.

1. year cells on "SourceData" sheet;

2. Sales Information Data on "SourceData" sheet;

3. "SourceData" sheet fee information data;

4. "Metadata" sheet cell;

Since data needs to be output in four places, you need to define four Excel Writer steps in conversion. The problem is that kettle is executed in parallel during conversion. If an excel file is written in four steps at the same time, an error occurs. Therefore, make sure that the execution is performed in order. We can define four transformations and then call the four transformations in sequence in the job. Because the job is executed sequentially, it is not very convenient. Usually unrelated data needs to be filled in to the same excel file. It is best to define data in a conversion for easy maintenance. This article uses another method to implement sequential execution. See:

Ensure sequential execution

Writing an excel file in conversion requires four steps, in the order of year, sales, expense, and report metadata cells. In the Excel Writer step, you must configure the file to be written to the same file, that is, the file copied from the template file. Therefore, configure the template file and create a new output file in the first step (year writing step. For other excel writing steps, you only need to configure the output file (because it already exists ), however, you also need to select the "wait for first row before creating file" option (do not create a file before receiving data ), this ensures that the output file is searched only after the first data is received.

When receiving the first line of data, all the operations in the previous Excel write step are completed. Here, the "Block until steps finish" Block the step. The year write step is the first execution, so you need to configure the template file and create the output file, and write the year data. The sales write step is waiting for the year step to complete, the cost step is waiting for the sales step to complete, and the metadata step is waiting for the cost step. The result is like a precise chain step, waiting for each other, and finally writing their own data.

If you use version 3.2 or 4.0, the blocking step is invalid. Check the corresponding version in the attachment and use the javascript step instead.

Style Problems

Write Data to the template file and keep the style unchanged. Select the corresponding options in the Excel Writer step.

In addition, formulas in the workbook need to be recalculated. Because of the Excel version, file type, and other possible conditions, the calculated cell value is not automatically updated when the generated file is opened, the cell formula can be automatically re-calculated in the Excel writing step, and corresponding options are available. However, some functions or Naming types are not supported by the poi Library at the moment, and an error may be reported, try to rewrite the formula, change the xls file type, or manually activate the technology (ctrl + shift + alt + F9 ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.