Best way to export data to Excel [duplicate] - c#

This question already has answers here:
How can I export data to an Excel file
(7 answers)
Closed 7 years ago.
I am new to C#. I am currently learning how to write a window form application. I want to export some of my data from my form to an Excel file.
I am wondering what is the best way to approach this problem?
I have looked through many tutorial site and YouTube video and most of them suggest to use a data grid view. One thing I notice is that datagridview work well with simple GUI layout like the textbox.
However, what if I have some other complicated components such as a checkbox and a comboBox in my form?
Data grid view seems not the best option to do it. Are there any other better solutions to this case?

The approach depends on the desired result. As far as I know, Excel is able to import from a delimiter-separated text file. Depending on the context, it might be a valid approach to programmatically write to a text file which is then read by Excel.

Related

Copy excel template and edit in memory using OpenXML [duplicate]

This question already has answers here:
How do I export to Excel?
(3 answers)
Export DataTable to Excel with EPPlus
(5 answers)
Closed 4 years ago.
My requirement is to open an excel template and edit in memory and then download to user. This needs to be done in .net MVC web project so I tend to use OpenXML instead of InterOp.
The whole idea is I have an excel template which has two sheets. Second sheet contains a set of datasources which I have bound as a range selector in first sheet cells. Now, based on which user is logged in, I need to change the data in datasources and same will be reflected into the first sheet.
This template is added into the project. For concurrency, I don't want to edit this template. I am thinking to either make a copy of this and download it to temp or best if I can take the snapshot of this template in memory and edit the sheet to and then stream it to the response for user to download.
Any help, links, articles based on OpenXML SDK will be really helpful.

looking for alternative to Excel spreadsheets as a data collection mean [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Someone wants me to implement a server side data extraction service to extract data from Micorsoft Excel 2010 spreadsheet (xlsx). A spreadsheet must have data in the correct places in order for the extraction to work. Is there a better alternative to using spreadsheets as data collection ? I worry that users might produce a spreadsheet that can fail a parsing/extraction method even though the displayed spreadsheet is understandable to a human.
For example , a user needs to type out many items and each item will several detail lines following it. My program will need identify the boundary between each item and then collect the detail lines that follow it. If a extraction fails, a user will need clues to help them to fix the problem and then re-submit the xlsx file again.
Is there a better way ? Is there something as portable as a Excel spreadsheet but has structured data that can be easily extracted ?
Or perhaps can a Excel spreadsheet to prepare data into structured data such as a JSON representation and then store it as part of the open xml package ?
You can improve data collection using Excel by using Named Ranges and adding Validation code that runs on data entry to the spreadsheet. The Validation code could also add metadata tags to the workbook. Then your extraction program can use the Named ranges (and metadata) to find the data.
I would use an Access DB, very portable but allows you to password protect the structure or only allow insert via a form.
Also an access DB can be read easily via the Jet engine so extracting data automatically in C# is fairly straight forward.
If I understood you question right - you want to store some custom XML describing your data inside you OpenXml Excel file. I think you could use Custom XML Parts for that.

asp.net + c# tips to edit docx inside my app [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Open/handle Word documents like SharePoint
I´ve developed one website where it is possible to upload docx files to it. Now I want a way to edit it directly in browser, I meant, a way to do like google docs does.
OR
Copy from MSWord to my app window e maintain all the formats, including tables.
for the manipulation of word documents you can use DocX. With this you can read/write from/to word documents (docx not doc). This however is a long way from editing your document in a google docs like manner...
It does match your second request though!

Silverlight: Is it possible to syntax-colour XML in a textBox? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Silverlight XML editor / syntax highlighting
Hello,
I have some XML in my Silverlight Application that I store in a String and wish to output to the user. The xml is already "pretty printed" in the sense that it is formatted with indentations, but it would make it much clearer to read if I could also add syntax colouring to it.
Can this be done? How do I go about doing it? (please suggest a library or something)
Come to think of it, I'm not even sure if it's at all possible to output coloured text in a .NET interface...
Thank you for any insight!
(PS: I don't care which version of Silverlight)
I looked and did not find a control that would do XML syntax highlighting for a WinForms RichTextBox. This was for an XPath evaluator tool I built. The WinForms RichTextBox has the capability to display colors of course, but I couldn't find one smart enough to highlight XML syntax.
I ended up building one. The approach I used would probably work for WPF as well.
This is the explanation for how I got there:
WinForms RichTextBox : how to reformat asynchronously, without firing TextChanged event

Best way to print a datagridview with all rows and all columns? [duplicate]

This question already has answers here:
Printing a .NET DataGridView
(9 answers)
Closed 8 years ago.
I need to add some functionality to be able to print whatever is displayed in datagridview. I tried to use bitmap class but it does not seem to be printing all the rows and columns. It looks like a screenshot and missing some columns and rows.
Anybody knows any better way to handle this? Thanks so much.
There are some examples/utilities on CodeProject:
http://www.codeproject.com/KB/printing/PrintingOfDataGridView.aspx
http://www.codeproject.com/KB/printing/GridPrintPreviewSolution.aspx
http://www.codeproject.com/KB/printing/GridPrintPreviewSolution2.aspx
http://www.codeproject.com/KB/printing/DGVPrinter.aspx
Check this link :
How To Print a Data Grid in C# and .NET
And Have you tried creating local report (rdlc and using Reportviewer)?
This will also help you to create custom reports..
Regards

Categories