在SSIS包中,我需要将2个SQL查询的内容放在2个Excel文件中。 2个查询的结果是2个对象变量,我想知道我是否可以使用数据流任务。问题:
final int[] ints = new int[]{32, 25, 56, 56, 12, 20, 22, 19, 54, 22};
Arrays.sort(ints);
System.out.println(Arrays.toString(ints));
答案 0 :(得分:2)
作为一般答案,不,你不能用SSIS做到这一点。但是,由于您使用C#对其进行了标记,因此可以使用OLE将工作表添加到Excel文件并将数据添加到这些工作表http://jayadevjyothi.blogspot.com/2013/01/step-1-create-new-project.html。这可以在SSIS之外完成,或者如果您的解决方案需要在SSIS中运行,您可以将C#放在脚本任务中。
// Excel file path
string excelFilePath = @"F:\Excel File.xlsx";
// Connection string for accessing excel file
string connectionString = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0}; Extended Properties=""Excel 12.0 Xml;HDR=YES""", excelFilePath);
using (OleDbConnection Connection = new OleDbConnection(connectionString))
{
try
{
Connection.Open();
using (OleDbCommand Command = new OleDbCommand())
{
Command.Connection = Connection;
Command.CommandText = "CREATE TABLE [Students] ([First Name] Char(200), [Last Name] Char(200), [Age] Char(2))";
Command.ExecuteNonQuery();
Console.WriteLine("Table Created Successfully");
}
Console.ReadLine();
}
catch (OleDbException ex)
{
Console.WriteLine("Message: " + ex.Message);
Console.ReadLine();
}
finally
{
Connection.Close();
}
}