简体   繁体   English

使用SSIS导出到Excel时保留公式

[英]Preserving Formulas when exporting to Excel using SSIS

I'm currently using a template to generate Excels to export data from my DB to daily reports using SSIS. 我目前正在使用模板生成Excel,以使用SSIS将数据从数据库导出到每日报告。

This template is a workbook of about 5 worksheets, of which only 1 needs to be filled automatically. 该模板是一个约5个工作表的工作簿,其中只有1个需要自动填写。 This sheet has about 20 columns, of which 2 use Vlookups to auto-populate values based on the value in the preceding column. 该工作表大约有20列,其中2列使用Vlookups根据前一列中的值自动填充值。 This is like an ID-Name pair. 这就像一个ID-名称对。 I need to make ID population part of the export from my DB, while the Name should be populated automatically. 我需要将ID填充作为从数据库导出的一部分,而Name应该自动填充。 This ID-Name relation is maintained in Sheet 2, which I am not touching. 此ID名称关系在表2中维护,我没有碰过。

My problem is THIS : The formula is applied to these two columns for about 150 rows (i don't expect more records). 我的问题是:此公式适用于这两行约150行(我希望没有更多记录)。 So, if my DB returns 120 results, I want my final Excel report from SSIS to have records from A2 to T122. 因此,如果我的数据库返回120个结果,则我希望SSIS的最终Excel报告具有从A2到T122的记录。 However, what's happening is that once my SSIS package executes, I'm getting an Excel file with the first 150 rows blank... and then my 120 results are filled in. These formula-based Name columns have values "#NA" when the ID column is empty. 但是,发生的事情是,一旦执行我的SSIS包,我将得到一个Excel文件,其中前150行为空白...然后填写了我的120个结果。这些基于公式的“名称”列在输入时为“ #NA” ID列为空。

How do I tackle this? 我该如何解决? Would I be able to work around this if I redesigned the Excel formulae to store an empty string instead of #NA when no ID value is present? 如果我重新设计了Excel公式以在没有ID值的情况下存储空字符串而不是#NA,我是否可以解决此问题? My end-user needs these formulae to be preserved in his final Excel output. 我的最终用户需要将这些公式保留在最终的Excel输出中。

I'm not fully sure if you can design a Vlookup that populates empty strings if the reference field is empty, but that's the first suggestion I thought of. 我不完全确定是否可以设计一个Vlookup,如果参考字段为空,则填充空字符串,但这是我想到的第一个建议。

My understanding is that the SSIS engine is probably seeing these #NA values and assuming that these rows already have meaningful data, and thus sidestepping rather than overwriting them. 我的理解是,SSIS引擎可能会看到这些#NA值,并假设这些行已经具有有意义的数据,因此回避而不是覆盖它们。 There could be an Overwrite property somewhere, that I haven't found yet. 我可能还没有发现某个地方的Overwrite属性。

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

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