简体   繁体   English

使用 Talend Job 在 excel 中添加数据透视表的最佳方法是什么?

[英]What is the best way to add a pivot table sheet in excel using Talend Job?

I am developing a Talend Automation Job ,我正在开发一个Talend 自动化工作
where I need to fetch my data in a " data " sheet in Excel.我需要在 Excel 的“数据”表中获取我的数据。
And then add a summary using Pivot table in excel in a separate sheet " Segment_Summary "然后在单独的工作表“ Segment_Summary ”中使用excel中的数据透视表添加摘要
in same excel workbook.在同一个excel工作簿中。 (using Excel 2016) (使用 Excel 2016)
Then send it in tsendMail to clients as attachment.然后在tsendMail 中将其作为附件发送给客户端。

Can you tell me a better way than what I did as explained below?你能告诉我比下面解释的更好的方法吗?

So, here is what I tried doing:所以,这是我尝试做的:

I created a sample Workbook with " data " sheet .我用“数据”表创建了一个示例工作簿。
Selected cells of " data " sheet and created a named range for them.选择“数据”表的单元格并为它们创建一个命名范围。
Then added a pivot table on that named range in new sheet " Segment_Summary ".然后在新工作表“ Segment_Summary ”中的该命名范围上添加了一个数据透视表。
Also set my Pivot Settings to Automatically Refresh whenever File gets opened.还将我的枢轴设置设置为在打开文件时自动刷新。
Inside Talend , I fetch my data into a new excel file using tFileOutputExcel .在 Talend 中,我使用tFileOutputExcel 将我的数据提取到一个新的 excel 文件中。
Copy Segment_Summary sheet from my Sample Workbook into this new excel file using tFileCopy .使用tFileCopySegment_Summary表从我的示例工作簿复制到这个新的 excel 文件中。
Using tsendMail sent the excel as attachment使用tsendMail将 excel 作为附件发送

What happened to the output :输出发生了什么:

Executed my job,执行我的工作,
checked the new Excel created.检查创建的新 Excel。
Its good, pivot is automatically refreshed to new data .它的好,pivot 会自动刷新为新数据。

So what goes wrong here:那么这里出了什么问题:

When I download the file from mail and then open it, pivot is not refreshed.当我从邮件下载文件然后打开它时,数据透视没有刷新。 This is because by default MS Excel opens every file in Protected Mode and disables Editing.这是因为默认情况下 MS Excel 在保护模式下打开每个文件并禁用编辑。 So, when clients will open this file, they will see outdated data instead of refreshed one.因此,当客户端打开此文件时,他们将看到过时的数据而不是刷新的数据。

(I cannot simply write in mail that open it in editing mode, as this has to be sent to many people..and my email template is word-to-word decided by sales.) (我不能简单地写在以编辑模式打开它的邮件中,因为这必须发送给很多人......我的电子邮件模板是由销售人员决定的。)

doesn't tFileCopy copy files? tFileCopy 不复制文件吗? How are you using this to copy a single sheet from an Excel file?您如何使用它从 Excel 文件中复制单个工作表?

Given that Talend doesn't "understand" Excel - only data and files - the only approach I can think of that might work is to have your target Excel file already containing the pivot table and then use Talend to update the sheet in that target file that contains the raw data.鉴于 Talend 不能“理解”Excel——只有数据和文件——我能想到的唯一可行的方法是让你的目标 Excel 文件已经包含数据透视表,然后使用 Talend 更新该目标文件中的工作表包含原始数据。

I'd probably create a template Excel file with example data and a pivot table and then in each run create a copy of this file and update the copy.我可能会创建一个包含示例数据和数据透视表的模板 Excel 文件,然后在每次运行时创建该文件的副本并更新副本。

Given that the size of the raw data is likely to change from run to run, you're probably also going to have issues with the named range that the pivot table is using - assuming the named range is fixed.鉴于原始数据的大小可能会随着运行而变化,您可能还会遇到数据透视表正在使用的命名范围的问题 - 假设命名范围是固定的。 Having a dynamic named range may be needed, this link explains how to implement this, if you need to know: Dynamic Named Range可能需要动态命名范围,此链接解释了如何实现这一点,如果您需要知道:动态命名范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM