I'm currently writing a C# 4.5 desktop application intended to help troubleshoot an old VPF application. My app is intended to display a list of things that can commonly be broken along with their current status.
A few of the things I need to display are found in the VFP application's databases so I need to be able to read DBase databases. However, I have a few restrictions that make this tricky:
I can't guarantee that any DBF driver has been installed on the system.
My application should run without a separate installer so I can't just toss in the ACE redistributable. (I could install ACE together with the VFP app but I don't want to rely on any part of it being intact, even bundled libraries.)
Is there anything I can bundle with my app that can read VFP databases and doesn't require installation?
I wouldn't want to do this... but you could parse the files yourself.
It looks like someone on github has the same idea.
As Tom said,
You can parse DBF files yourself. Their structures are well documented.
As a side note, ACE has nothing to do with VFP database files and actually ACE cannot read/write DBF files (unless they are old DBF formats). Proper VFP database driver is VFPOLEDB which you can include its setup msi with your application. Using VFPOLEDB would be an easy path.
Related
I've been tasked with a feature that can generate PowerPoint files on the server using C#. I'd basically start with a template, and programmatically replace some text with live data from the database. I've been doing some research into this area for the past day and here's what I've found:
PowerPoint has this sort of thing built in, meaning it can connect to external data sources and pull in data. Most examples of this, I've found, either use PowerPoint automation done on the server (I've been advised against this) or assume a SQL Server backend. Our company uses Oracle for our RDMS needs. Oracle has a solution for this called Oracle BI, but it requires a whole new web server setup to run various Java EE components and what not. I didn't look at the price, but knowing Oracle it's not cheap. It also requires new software to be installed on the end user's machine, which we really want to avoid.
Generating PowerPoint files on the fly is possible. The company that is basically the go-to guys for this problem (every help forum points to them, and they get all the rave reviews) is Aspose. They have .NET components for dealing with just about any Office format you can think of. The problem is, they are astronomically expensive. Just the PowerPoint component (a site license for up to 10 developers) would cost $3,995.
The third possibility is generating a solution in-house. After all, a PPTX file is just xml, right? Well, looking closer, a PPTX appears to be a gzip archive. It contains many folders, each containing many XML files. Modifying a PPTX file would, correct me if I'm wrong, entail unzipping the file to a temporary directory, reading the XML file and modifying the contents, then packaging up everything again and write the file out to the response stream. Perhaps there are libraries that can work with gzip streams on the fly without extracting everything.
My Question: Are there easier ways to work with a PPTX file using .NET that don't require working with compressed XML files or buying very expensive software? Basically, we need to modify a PowerPoint file, change some text, and allow the user to download that generated file from a web server.
OpenXML is Microsoft's .Net library that lets you manipulate Office documents. It lets you open a PPTX file and provides an object model that wraps the XML contents.
Here's the link to the OpenXML SDK and the MSDN documentation.
I've used OpenXML to let a ASP.Net page dynamically generate Word documents from a database.
Don't use Office Interop on a web server. It's an all-around bad idea.
If you are only replacing text placeholders for files that will not change, the home grown solution that finds the placeholders in the xml files in the gzip archive should be doable. .Net has had zip support for some time, and it is greatly improved if you are able to use .Net 4.5, so you shouldn't need to extract the archive to a temporary location at all.
PowerPoint should also support connecting directly to Oracle in the same way it supports connecting to Sql Server (just play around with the connection options), without needing the special Oracle BI stuff. However, I'd still prefer the home-grown solution, as this will only work while the powerpoint file is able to reach your database directly, which is typically only possible in your local LAN environment or with an active VPN.
If you want anything fancier than a simple text replacement, perhaps looks for an Aspose competitor.
I'm developping an application for Honeywell Dolphin 6100, a mobile computer with a barcode scanner that uses Windows CE 5.0 like OS.
I want to import data from excel file to the local database of the application. I'm following this tutoriel
The problem is that the System.Data.OleDb can not be found which is important to read data from an external file.
What I need to do ?
Note: I'm using VS2008 and I'm working on Windows 7.
You have a raft of hurdles to overcome. Just a few are
OLEDB is not supported under Windows CE.
Pocket Excel has no automation object model or even any published file format specification
Desktop libraries (like Microsoft.Office.Interop.Excel) will not work under Windows CE
Basically I think you're straying down a poor choice path.
What's the actual business problem you're trying to solve here? Do you have Pocket Excel files created on the device you need to merge into a local SQL Compact Database? Is there an option for not using Excel? Or is it that you have desktop Excel files on a PC and you want the data over on the device? If so, how are the files getting to the device? Can you convert them to CSV? Can you put a service on a server somewhere to do the conversion for you?
There's likely a way to solve the overall problem, just not on the path you're trying. We'd need to understand the actual problem to help you get a better solution, though.
some options:
write a one off console app to do the import.
use SQLserver management studio to do the one off import of an excel file
use microsoft access which will allow you to open the excel file and the DB and query across them both.
Unless you need to have your CE app accessing excel files all the time then maybe its not worth getting it to work just now.
I am working on some software that uses an OleDB to open a .xls file, query some data, and fill a dataset with the results. I am now looking at using this software on systems that do not have Excel. Will my software still be able to read the spreadsheets?
This xls file contains 1000s of configuration settings that my software uses. If this setup won't work on computers without Excel, I'm guessing my next best move is to convert the xls file to an XML file and read it in using XML Services.
You don't have to have office or the office data connectivity installed, you can use the Jet for OleDB engine which is installed on pretty much every windows machine in existence. However it's very old technology and is limited to 32 bit.
http://msdn.microsoft.com/en-us/library/ms175866.aspx
If you want to avoid this mess entirely then switch over to an app.config file or a properties file and you can get the pure .net solution.
You need either the full Office or the Office Data Connectivity Components installed on the client computers.
I generate files, lets call them .dwrf files, which contain a significant amount of data. Currently we export those to .CSV and the resulting files are large (2GB+). I would like to cut out the export process and make the contents of a .dwrf file queryable directly from Excel or other applications.
What I would like to do is write a utility/service - lets call it dwrfMiner - to extract data from the file and pass it on as a datasource and link dwrfMiner to .dwrf files in some way so that Excel recognises it as an external data source.
Any ideas?
While writing an ODBC driver for this is probably overkill, if the format of the files you are working with is known in advance and isn't too hard to translate (it sounds like not considering you are already creating CSVs) then using an ODBC DSN sounds like your best bet.
There are a nice selection of ODBC drivers already built in to Windows (.txt, .csv, .mdb, .xl*, .dbf, Paradox .db, etc etc) and you can obtain other drivers from the web for a lot of common formats.
If the size of the existing format you're exporting to is too onerous (CSV) then the logical point to start is a transformation of your data to something more space-conscious that has ODBC support.
Failing that, your last option is the overkill option (Writing an ODBC driver).
Excel can query external data souces, but beware that Excel (all versions) have hard-limits on the number of rows they can display, per work-book. I think in Excel 2003 the limit is ~65k. It's higher in other versions.
See my question: reporting tool/viewer for large datasets (and I had much less than > 2GB).
I used PHP FlatFile DB to query flat-files in the past
I'd get out gcc and write yourself a full ODBC driver for it. Then you can sit back and use SQL.
You know, if you're bored. ;)
use odbc driver with multithreading
Consider i have an excel file >200000 rows in it. What is the fastest way that can be implemented to search a partcular column value in this file using c# asp.net. Any suggestion.
Assuming 1) you can cache the file contents fine (not too large, file doesn't change, etc) and 2) you don't already have a mechanism for reading the file, I would just read the file once (at application start, or lazy load on demand, or whatever) into memory - I have used and really like the FileHelpers libs from http://www.filehelpers.com/ - see their excel example # http://www.filehelpers.com/example_exceldatalink.html
as part of the 'read in the file', you'd likely also create some indexes for the later queries. If you only cared about the one column, you could just push it all into a HashSet, for instance, so you can do a Contains later quickly.
You cannot access an Excel file from ASP.NET at all if you are using the Excel Automation APIs. These were written for use in a desktop application, not in a server application like ASP.NET. They will not work, are not supported, and may very well violate your license agreement with Microsoft.
There are third-party libraries that can access an Excel file safely from ASP.NET. These do not use the Automation APIs.
You may want to consider using an "OLE DB for Jet 4.0" connection, which you can query via ADO.NET. OLE DB access to Excel is provided via the MDAC component, which comes standard on versions of Windows after 2000. ConnectionStrings.com has OLE DB connection strings for connecting to Excel, as well as information on using Jet in a 64-bit environment.
Use EPPLus and read the file into an DataTable.
Could take some time, that file is a little bit big...