SSIS-将SQL导出到Excel-日期格式问题

问题描述 投票:0回答:1
// for colomn L InqDate_Current // Set the data type of the entire column to date Microsoft.Office.Interop.Excel.Range column_L = worksheet.Columns["L"]; column_L.NumberFormat = "yyyy-mm-dd"; // Get the range of the used cells in the column Range usedRange_L = column_L.Cells.SpecialCells(XlCellType.xlCellTypeConstants); i = 0; // Loop through each cell in the column foreach (Range cell in usedRange_L) { if (i != 0) // Convert cell value to integer and assign it back to the cell { cell.Value = cell.Value; } i++; }

在我的SSIS软件包数据流中,我有三个步骤:

通过OLE DB源retried数据
将数据转换为正确的数据类型(数据转换转换编辑器)

excel中的save data。
  1. 控制流,数据流完成后,有一个步骤运行一个C#脚本,该脚本适用于特定列以更改数据类型。
  2. 我希望日期列为真日期列。
  3. 你对我有任何见识吗?
  4. 谢谢你!

不确定您所说的“真实日期”。 在Excel中,所有日期都是数字(代表日期时的整数),格式为日期。

,您的代码中的这一部分似乎没有很多意义。

{ cell.Value = cell.Value; }

我认为您要做的是不仅仅设置NumberFormat,而是需要明确将单元格值转换为C#脚本中的日期:

thim,例如:

c# excel ssis export-to-excel
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.