Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi,

I have created table in sql server with file name ,path on which its get generate.
how can i create excel dynamically all the list of files stored in table in given path using c# code.

What I have tried:

created table with the field
1.filename
2.path
3.filter like country details i wana show in one of file the column name is india
how can i used this information to create excel file dynamically in c sharp .net
Posted
Updated 29-Oct-18 8:32am
Comments
OriginalGriff 28-Oct-18 2:17am    
What have you tried?
Where are you stuck?
What help do you need?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.

Use the "Improve question" widget to edit your question and provide better information.
Eric Lynch 28-Oct-18 16:35pm    
I do not intend to be unkind with this information. I realize language skills vary. I've worked in other countries where I did not speak the language. People were very kind to me there.

I hope to return the favor by offering the following glossary and suggestions.

In SQL, a "table" is composed of "columns". A "table" is uniquely identified by a "table name". For example, a table containing information about people might be named "People".

Each column has a "column name". For example, a column named "Country" might contain a value "India". It is unlikely you would have a column named "India".

A "row" is a set of values for the "columns" within a "table".

A "file" is typically something maintained by the operating system. While related, it is different/distinct from a SQL "table". A "path" is typically a unique identifier for a "file". A "file name" is typically a non-unique portion of a "path".

Different "files" contain different types of data. Excel would be one type of data.

Given this information, it would be helpful if you could do the following.

1) Provide the name of the SQL table that is causing you problems.
2) Provide the names (and data types) of the columns contained in this table.
3) Provide the names of the columns you want to (I think?) extract from this table and write to an Excel file.
4) If you are limiting the rows you want from this table, provide more specific information about this limit. For example, "WHERE Country = 'India'".
5) Be more specific about the format for your output file. For example, a CSV file (column-separated-value) is easily written and can be read by Excel. Is this sufficient? If not, writing a "true" Excel file is more difficult.
6) As OriginalGriff suggests, be more specific about the sort of help you need. For example, if you actually wrote some code that failed, share the code, share the error. We can all read code. There, language difficulties are less important.

Hope this helps you word the question. As written, its very difficult to help you.
F-ES Sitecore 29-Oct-18 6:49am    
Have a look at the Excel ODBC driver. You can google for examples of how to use it, but some code is here https://stackoverflow.com/questions/18767598/how-to-insert-query-to-excel-by-odbc-connection-in-asp-net

1 solution

Your "Excel" requirements can be met with a simple "csv" file (Excel can read / write csv).

c# - Export SQL Server Data into CSV file - Stack Overflow[^]

C# - CSV Import Export[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900