protected void btnExport_Click(object sender, EventArgs e) { PackageCreator packageCreator = new PackageCreator(); packageCreator.ExecuteMode = ExecuteMode.FileSystem; packageCreator.StagingFolder = @"C:\Temp\Drop\Staging"; packageCreator.AutoGeneratePassword = true; // Generates a dtsx file and return password. string password = packageCreator.CreateExportToFlatFilePackage( "MyExcelDtsxPackage", "SELECT [TRequestID], [CorrelationID], [UserName], [StartDate], [EndDate], [RequestStatus], [SubmitDate],[TrainingName] FROM dbo.TrainingRequest", @"Data Source=ENGSOON;Initial Catalog=HRTrainingRequest;User ID=sa;Password=CESoon1012", "MyGeneratedExcelFile", ".csv", "|", true, true); }