I need to install NPOI package into a SSIS task script

29 Views Asked by At

I would like to use NPOI package to convert a .csv file into an .xlsx. I am trying with NPOI package bcos I can not use ACE.OLEDB neither any library which need office installed on the machine.

Is the first time I tried to do this , so I followed these instructions:

https://blog.matrixpost.net/load-an-custom-assembly-in-sql-server-integration-services-ssis-script-task-that-is-not-or-cannot-be-stored-in-the-gac/

but does not work , when I run the corflags command appears it does not have access to read the folder.

SSIS error]

corflags error

Any advice would be great, thanks in advance!

--Attached a part of the script code.---------

#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
using System.Text;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using NPOI;
#endregion

namespace ST_14f74128896f4ec2939bbe171ead9c74
{
 
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        

        public void Main()
        {
            string pathCsv = Dts.Variables["User::Pathcsv"].Value.ToString();
            char splitter = ',';
            var newFileName = Path.ChangeExtension(pathCsv, ".xlsx");

            //All read all the lines present in the csv file
            string[] lines = File.ReadAllLines(pathCsv, Encoding.UTF8);

            //Create the excek file 
            IWorkbook workbook = new XSSFWorkbook();
            var sheet = workbook.CreateSheet(Path.GetFileName(newFileName));
            var rowIndex = 0;[....]

I tried to istalled the NPOI package using gac and customizing the package, but does not work. Furthermore, I installed the Npoi package through the Nuget package, but the script is not working.

I am not sure what else I can do or what I have done wrong.

0

There are 0 best solutions below