It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Am using Microsoft.ACE.OleDb to write data to excel. I want to format the worksheet by using Microsoft.ACE.OleDb only? My requirement is i dont want to use 3rd party libraries like Microsoft.InterOp and EPPlus. How can i do this?
No, you can't. Microsoft.ACE.OleDb allows you to operate data, not to format cells and text
If you don't want to use Interop.Excel, you should look at Late binding
The only reliable way to create a real Excel worksheet with formatting is using Aspose.Cells for .NET.
There also is ExcelPackagePlus on CodePlex, which is opensource, but it has a bug that prevents reading or writing workseets when your text contains a www/mail-Link that is invalid, e.g. a password that contains an # sign, with excel incorrectly interpreting this as a link.
There is also carlosag.excelwriter, but it doesn't really create an excel file, it creates an XML file that can be read and displayed by excel.
Excel 2010 however issues a warning, "Not a valid excel file", that may potentially scare off users.
I would not recommend using ACE.OleDb, you will run into 32/64 bit issues, as the ACE drivers are already on life-support and deprecated and thus not available on 64 bit windows (matters if you have 64 bit excel as well).
For the same reason, I would not use Interop.Excel.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am looking for a way to import csv files with schma (.ini file).
I want import the csv into a datatable.
I don't want to use excel interop, because of known issues in running it on windows services.
Is there a way to do so in another tool or technology such as OpenXML?
I've already tested Aspose's and Syncfusion's tools - and it seems they can't offer a solution here. Would appreciate any help.
You can do this with an ODBC connection, which treats the text file as a database. Just make sure the .ini file is in the same location as the text-file.
Recording a macro in Excel from the following steps will give you some base code to work with.
Data > Import External Data > New Database Query
Select In Create New Data Source,
choose a name
select the driver - Microsoft Text Driver (*.txt, *.csv)
click Connect and in ODBC Text Setup select the folder containing the csv file
select a default table - the csv file (optional)
A similar process can be coded in C# without using Interop. It just uses a database connection, probably OleDbConnection.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am writing a C# asp.net web application that receives CV's in various formats i.e. doc, docx, pdf, text, etc.
I was wondering if there was a simple way I could remove certain information from the document not matter what file type it is and then pass on the edited file to the end user?
The information to be removed will be held in a string
You will need to parse each file type using separate APIs.
.docx can be parsed using: http://docx.codeplex.com/
.pdf can be parsed using: http://www.pdfsharp.net/
etc.
If you use a streamreader (http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx) to read through the document, you could use the ReadToEnd function to store everything in a string, then use the function:
MyString.Replace("Something to replace", "");
to remove the matches. If the file formats cannot be read in as a string, you'll have to consider different options. However, there are likely faster solutions given the file formats, and it's likely not stored as simply.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm sorry but it seems a very silly question, but if i have a format let it be .epub for example and want to build a class (C# class) that can read it, what should I do. I'm not talking about a certain format or certain language, but I'm asking about building an interface that can read/write this format. vaguely I guess COM object should do this but i haven't dealt with them and get tired of learning any concepts and technology to find that it is irrelevant to my needs. thank you in advance and sorry for this very loose. question
If you know the format of the file then the only specific thing you need to do is create a class that will read/write that format. The internal structure of the class can be represented however you want.
To write the format just use System.IO.FileStream and/or System.IO.StreamWriter. If the file is represented in hex data then use a BinaryReader or BinaryWriter.
The process of reading/writing a file is then just a matter of parsing the data into your internal representation in code, when reading, so you can edit it and then writing out the data according to the file format spec.
Here is a link on file formats just in case. If you have a more specific question ask it and you can get more specific help and/or examples.
EDIT:
If you are looking for the EPUB spec it is Here. I'm afraid that you are going to have to read the spec for any file format that you plan on creating a class for, which can be tedious. I had to do this for PDF documents recently. Just make sure you can understand the spec, look at examples and try different things out when writing/reading. This is really the only thing you can do.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
i read a zip file in my application and i don't want to extract after i read it all ..
i want to extract it while i am reading it.
so how do i extract stream of bytes for a file while i am reading it ?
The GZipStream and DeflateStream classes are wrappers around a normal Stream object. This means that you can extract the data as you're going along before a) the whole file has been downloaded and b) without loading all of the data in to memory.
These are available in .NET 4 upwards, otherwise you'll need to use #ZipLib as suggested.
EDIT:
After looking around it would appear that #ZipLib is definitely the way forwards with this. The same principles apply to these classes in that they are streams, they can work as the file is being downloaded or read over a network and they don't require the whole file to be in memory. I'm currently using it in a project to open zip files from an http server, so I've seen it in action!
The .NET Base Class Library doesn't include classes to stream .zip files. Take a look at SharpZipLib.
Here are various examples of compression/decompression using the #Zip library.
http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to read and display the contents of the PDF files into my RichtextBox. I am using windows application C#. Is it possible? What is the way to do it?
You can use Adobe PDF IFilter Library to convert a PDF document to text.
Also see an example on the CodeProject
iTextSharp is another alternative PDF library for .NET.
Since PDF is an binary format you'll have to use a pdf-library like pdflib in order to read pdf-files.
pdfLib
You should checkout PDFSharp library and they have preview component, where else extracting text and showing them in RichTextBox could be little bit of more work, but you can try this.