Open an Excel File on Sharepoint from SSIS Package without moving it - excel

I'm trying to change some Excel Files which are laying on SharePoint.
This should be performed automatically while my Import to SQL-Server is running. For the Import I'm using a SSIS.
Is it possible to change Excel Files with SSIS? And hwo is it possible?
By the way the SSIS package should open and close the the Excel files so that I got no interferences through open packages.
I'm Using Excel 2013, SQL-Server and Visual Studio 2013

You can use the following code to open Excel-Files on SharePoint:
Dim process As New System.Diagnostics.Process()
process.Start("filepath")
process.Close()
If you get the Excel- File as .xlsm file you can directly process the macro. If you get an .xlsx- file you need to make an extra file which can process macros and then you process the new file.

Related

EPPlus Adding VBA Code Corrupts resulting xlsx file

I'm creating an excel file using EPPlus from a datatable and saving it to a file, all fairly standard. This works without any hassles. However, if I create a vba project, and add any vba code, the resulting .xlsx file is suddenly corrupted. When try and open it with 2013, you get the standard error.
"Excel cannot open the file 'xyz.xlsx' because the file format or file
extension is not valid. Verify that the file extension matches the
format of the file.
If I change the extension to .xls, the file opens ok, and the script runs fine. I'm on the latest beta of Epplus (4.5.0.1). Should I just change the file extension and stick to .xls, or is there something amiss?
ExcelPackage.Workbook.CreateVBAProject()
ExcelPackage.Workbook.CodeModule.Code = "'Script is here"
Dim FInfo as new FileInfo("C:\Myfiles\ThisFile.xlsx")
ExcelPackage.SaveAs(FInfo)
You can not add VBA code to XLSX file format.
Take a look at here
.xlsx:
The default XML-based file format for Excel 2007-2013. Cannot store
Microsoft Visual Basic for Applications (VBA) macro code or Microsoft
Office Excel 4.0 macro sheets (.xlm).
Also take a look at here
to see differences between different formats:
XLSM If you include VBA macros in your XLSX file, you will be asked to
change the file extension to XLSM. Only that way you can save your
macro within the Excel file (there are other file types possible, e.g.
XLSB – but you can’t use XLSX for VBA macros)
Save your file as XLSM and it should work.

Make a VSTO Excel 2016 Workbook Application portable/without setup?

I have the following situation:
I developed a VSTO Excel 2016 Workbook, which triggers some code when you copy/paste an Excel Worksheet in the above mentioned Workbook. When i publish the project (Project Properties > Publish > Publish Now), Visual Studio creates the following in Folder:
Excel Workbook(.xlsx)
VSTO file(.vsto)
setup.exe file
The Workbook only opens without error when i first run the Setup, wich obviously installs the .vsto file.
My Question:
Can you generate/publish a .xlsx Workbook which is portable, i.e. you dont have to install anything since the Code is already in the .xlsx file? Because I dont want to run the setup.exe everytime when i switched to another PC.
Or is there even an alternative solution to VSTO/my problem?
The only way to embed and distribute code with a workbook is to use VBA.
There is no way to embed a VSTO solution in a workbook - VSTO was explicitly designed to not allow that for reasons of code maintenance and security.

Excel file locked after opening in Microsoft Data Report Designer

I develop an application in VB6 and my data source is Excel 2007. And I have created 2 reports in Microsoft Data Report Designer.
My program is working. I can save data (update)in excel file and view existing data via VB6. And I have written code to backup (copy paste) the excel file in another folder. This is also working as I wanted.
But after I open or view the DataReports, I cant save the data in the Excel and backup the excel file. Then I will have to close the application to update and backup excel sheet.
When I try to save data in Excel file after viewing the report I receive the message
The excel file already exists
When I try to backup after viewing and closing the report I receive the error message
Run time error 70" Permission denied
Need help please.

SSIS - Can't open Excel file in protected view

I'm running into a strange issue when trying to load excel spreadsheets into my database through SSIS (2012).
I'm getting the spreadsheets (which are xlsx files) via email, and then I manually save them to my local drive (C:\temp). When I try to use the excel file as a source in SSIS, I am not able to pick any excel sheets in the book.
The file is not corrupted, not open on my machine, and not password protected. It is, however, opening in Protected View. So I go into Excel and turned off all the Protected View options, but no cigar. The only way I am able to use the file as an excel source in SSIS is by opening it, and saving over it.
Does anyone have a similar experience? Other than opening and saving all of the files manually, is there a better solution?
It's a known issue with xml based excel (xlsx). If you can save them as xls, that will solve the problem. If for some reason that's not possible you may need to use OLE source to read them.

How to rename an Excel worksheet using OLEDB, ODBC or something else, other than an instance of Excel?

I am needing to rename an Excel worksheet that comes to us via FTP. The server the sheet resides on does not have Excel running on it so trying to script it via WSH and vbscript using Excel.Application is out of the question.
Is it possible to rename an Excel worksheet via OLE DB, ODBC or some other mechanism?
You don't need the Excel application to rename an Excel (.xls) file.
Or do you mean to rename a worksheet within a workbook?
Or create your vbscript that uses the Excel object model on a machine where it is available and pass it the full path to the file. Or you could fetch the file via another ftp onto the Excel enabled machine, rename it and ftp it back.
Just out of curiosity: Why do you need to rename the sheet? Is it ok to generate a new Excel file based on the contents of the old one? Can you alter the process that produces or consumes the file somehow?
The question What’s the best .NET library for parsing and generating Excel spreadsheets? seems to contain several pointers.
There are Perl modules for parsing and creating Excel files:Spreadsheet::ParseExcel, Spreadsheet::WriteExcel.

Resources