How to push data from excel spreadsheet to any application - excel

I need to push some 3000 entries from excel to an application called AMOS so could it be possible by excel vba or through some other utilities or applications.

AMOS doesn't support Excel data being programmatically "pushed in to it".
Instead, save the Excel data as file type CSV (Comma delimited) and then import into AMOS. You can create a CSV file programmatically if necessary.
AMOS can also import Excel 97-2003 XLS files, but not XLSX. You can save a newer file as XLS in Excel by choosing file type Excel 97-2003 Workbook (*.xls).
More info here.

Related

Delphi FireDac open excel xlsx file

I am trying to open Excel(xlsx) file using FireDAC Delphi Rio 10.3.2. I did the following code:
FDConnection.Params.Clear;
FDConnection.Params.Add('Database=<myfile>');
FDConnection.Params.Add('ODBCDriver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)}');
FDConnection.Params.Add('DriverID=ODBC');
FDConnection.Params.Add('ODBCAdvanced=HDR=No');
FDConnection.Open;
I noticed Delphi Rio FireDAC has up to Excel 97-2003
This is the error I am getting with FDConnection for xlsx file:
Can anyone please guide how to achieve Excel (xlsx) file open with FireDAC?
It is easier to use COM Access to Excel as per the following:SO:ADO access to Excel, but if you insist to use FireDAC, the following steps are necessary (checked for Delphi 10.2.3 Tokyo and MS Office 2016, have not tried to dig deeper why FireDAC does not perform these actions):
Define Name for the cells that contain the data to be accessed (with the header) in Formulas->Define Name
Excel must be running and the workbook should be opened (you can use COM to start Excel and make sure that the workbook is opened).
If the workbook was changed by inserting/modifying/deleting data, the workbook has to be saved.
If any of the above is not done, you will see the very meaningful message: External table is not in the expected format.
Because you need COM access to Excel in order to make sure the workbook is open in Excel, I would suggest to use the method 2) from:Excel sheet to Grid

Saving standard XLSM Excel with Macros as XLSB (Excel binary)

I have a large project with Excel VBA files. Planning on moving from the xlsm file format to the xlsb (Excel binary). When I save the xlsm file as an xlsb I get warning.
It displays "abc.xlsm contains features that this version of Microsoft Excel can't save in another file format. Do you want to continue saving in this format and remove these features?"
Didn't know that xlsm can contain stuff that xlsb can't. Would be curious to know what exactly that is.
Anybody got an idea what the problem could be?

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.

Export to Excel: programmatically create new Excel sheet

I need to export some data to Excel, and I'm building the document 'manually': strings with \t for new cell and \r\n for new line.
My question is how to insert in similar way new sheet in same document?
You export a CSV file, not an Excel file. MS Excel just opens CSV file and integrate file data in a sheet. You cannot have more than one sheet.
For exporting real Excel files you will an Excel library that can be integrated with your programming language.

Create an xls from a xlt

Ok I have a excel template file which contains various headers, images etc.
I need to populate a number of excel files based on this template file using Microsoft.Office.Interop.Excel
I have seen plenty of examples online how to create and modify existing excel files (both xlt and xls) however none show how to create the xls from an xlt.
The only way I can see round the problem is to open the xlt, populate the data on the workbook then save the file as an xls....
Is this the only way that this can be done?
Thanks
Instead of using xlt and xls files you can create a standard xlsx file and use unique tokens for the content you want to replace. Then you can create a new xlsx file based on your "template".
Open XML SDK 2.0 for Microsoft Office
http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

Resources