I am new in creating Report System using Visual Stuido 2010 C#. I already have a listview in my forms where it has all the information needed for the report. I am planning to integrate it with Microsoft Excel. What I want is that the user is capable of exporting the reports in the listview into Microsoft Excel. Is there anything I can read or research on how to do this? Or is it even possible? Please help. Thanks.
see:
http://www.dotnetlogix.com/article/aspnet/56/How-to-export-listview-in-excel-in-asp.net.html
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ExportASPNetDataGridToExcel11222005041447AM/ExportASPNetDataGridToExcel.aspx
Iterate the data source and write values into CSV (comma separated) file. I think this will be the simplest way. (Must read article : Why are the Microsoft Office file formats so complicated? (And some workarounds) by Joel Spolsky).
Related
I need to access word add-ins and sql database simultaneously. So embedding word inside C# winform is the only option. But Office above 2007 does not allow us to open word in C# winform web browser anymore. I am at total loss.
Any help is much appreciated.
This is written in a nice article by Bradley Smith
http://www.brad-smith.info/blog/archives/79
Is a nice guide and solution for your word files. Because you need to set the document to allowed to be a web view-able document. See the url for the code additions.
Regards,
Martijn
I am working on a project for Windows 10 UWP App. I have below two problems
1. I have to upload excel sheet containing the data, and store that
data into Sq-lite Database.
2. Also I have to read data from database table, and write to excel sheet in
rows and column format.
I have searched a lot but could not find any library or helping blog. I would be thankful for any complete guide or sample code. Thanks!!
I would suggest you use Syncfusion Essential XlsIO. It does the work for your read/write of excel files (also works with Xamarin and ASP.Net). It has a 30-day free trial but you can get a free community license.
Just so you know, thx to .Net Standard 2.0 we are able to use the OpenXML SDK! This allows you to create and/or manipulate MS Office documents.
As an example I've blogged about creating Excel files on the fly in Xamarin Forms ( that also can generate an UWP app ) here http://depblog.weblogs.us/2017/10/13/net-standard-2-0-create-microsoft-office-documents-in-xamarin-forms/
The SDK itself is open source https://github.com/OfficeDev/Open-XML-SDK and there is a very large detailed documentation site available too https://msdn.microsoft.com/en-us/library/office/bb448854.aspx
I have been struggling the last few hours trying to get an excel spreadsheet/workbook to be displayed on a Windows form using Visual Studio 2012, C#. I can retrieve the data from the workbook and display it on the form, but I need the functionality of Excel in the application, including stuff like Filtering, Conditional Formatting, Formulas, etc.
I have read up quite a lot, and as I understand it, there are no controls in Visual Studio to embed these (Office) files due to licencing, which makes sense. I have found a solution though, to display the file in a WebControl (I am sure I will be able to work with this), but when I try to load the excel file in the web control, it prompts the user to either open or save the file, and when 'Open File' is chosen, the file is opened using Microsoft Excel.
As I understand it, this happens because the ContentType (Mime type, Excel ContentType) of the file needs to be set in the browser (I need to do more research on this as I am not yet familiar with this concept, ).
The resources I am using:
Logic to save the contents to an Excel File: EPPlus
I was working from the following project, among others: Winforms Excel Example
The latter is almost exactly what I want to achieve, but keeps on asking to save or open the file, rather than just displaying it in the WebControl
Any help on this matter would be greatly appreciated.
There're commercial WinForms libraries from DevExpress, Syncfusion and Infragistics. I'm using DevExpress. I'd suggest their WinForms Spreadsheet control inspired by Excel. They also have Spreadsheet File API for .NET and Spreadsheet UI controls for ASP.NET, MVC, WPF, ASP.NET Core and Bootstrap.
You can try their free 30-day trial and see if DevExpress UI controls suit your needs.
Use DataGridView and program a functionnality if it doesn't have it!
OR
Use Excel COM to create an instance of Excel.
I have postcode level data in an Excel workbook and ideally I would like to have a map on another sheet of the area that I am interested in. The postcodes in my dataset should be highlighted within that map. I am using Excel 2010 and have no prior experience with GIS but plenty of experience with C#, Java. Any ideas of how I can achieve this? I looked for open source add-ins and didn't find an awful lot. Is there another way I can achieve what I want?
I use Topo.ly. You can just copy all your post codes from Excel and paste them in Topo.ly, and it will plot them on Google Maps. It also hosts your maps, so you can save it and come back to it later, or share it with others.
You can take a look to that solution for non-gis-users:
http://www.esri.com/software/esri-maps-for-office
It requires Office 2010 (that's no problem in your case) and it is based on a privative GIS software (no FLOSS). On the videos section there are some examples.
This can be a good starting point. You will need some knowledge of WPF
Bing Maps Windows Presentation Foundation (WPF) Control, Version 1.0
Then using VSTO you can integrate it into Excel
Using WPF Controls in Office Solutions
Sample WPF application is # Integrating Bing Maps With WPF
Edit :
Didnt find much on non WPF solution but you can give this a try
Integrating Virtual Earth Maps and Excel 2007 Using Visual Studio 2005 Tools for Office Second Edition
Download here http://archive.msdn.microsoft.com/VSTOVirtualEarthXL
For future reference or someone who has similar porblem, you can use an Excel add-in called Funfun to create data map in Excel 2016. I made two examples here.
As you could see, there is some code in the middle section of the screenshot. That is because Funfun allows you to write and run JavaScript code directly in Excel, also, the JavaScript code could use the data stored in the sheet. The capability of using JavaScript means that you could use 3rd party libraries like HighCharts.js or D3.js to plot charts like data map. In those two examples, I actually used highmaps which is part of the HighCharts.js library. The highmaps.js already has different templates from world map to specific map of different countries. I believe you could find the map you need.
Funfun also has an online editor in which you could test your JavaScript code with you data. You could check the detailed code of the examples above on the link below.
https://www.funfun.io/1/#/edit/5a5c9a50404f66229bda3ae0
https://www.funfun.io/1/#/edit/5925036104ce702ccfb22b0e
If you are satisfied with the result you achieved in the online editor, you could easily load the result into you Excel using the URL above. Of couse first you need to insert the Funfun add-in from Insert - My add-ins. Here are some screenshots showing how you could do this.
Disclosure: I'm a developer of Funfun
How can one read sql server data and write it to excel file in C#?
Do I need to use an external .Net library, or is it just OK using Visual Studio itself?
Any example and link will be well appreciated..
Note: Please send examples for Winforms, not asp.net
I would use some kind of OR-Mapper to read data from SQL such as
NHibernate
Entity Framework
Linq 2 SQL
For writing data to Excel you could bind hardly to any Excel Version by referencing the Excel Assemblies. The cleaner and more beautiful way is to use Open XML SDK for Office http://www.microsoft.com/download/en/details.aspx?id=5124
Follow the below article, this even provide the facility to export the data into many formats.
Export data to Excel and other formats using C#
see:
http://www.c-sharpcorner.com/UploadFile/DipalChoksi/exportxl_asp2_dc11032006003657AM/exportxl_asp2_dc.aspx
http://geekswithblogs.net/VROD/archive/2008/04/20/121433.aspx
You could find helpful information how to achieve that goal in the following blog posts:
1. http://msmvps.com/blogs/deborahk/archive/2009/07/23/writing-data-from-a-datatable-to-excel.aspx
2. http://tim.mackey.ie/HowtoExportADatasetToExcelCAspnet.aspx
See : http://www.dotnetfunda.com/forums/thread548-export-data-to-excel-file-from-a-table-in-sql-server-using-csharp.aspx
It also has a nice example on the link inside the page.