Reading and Writing to Excel sheet in C# UWP Windows 10 App - c#

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

Related

Visualise map data in 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

I need a standalone .net dll to process openxml spreadsheet formulas realtime

I am writing an application that will live on a server I will not have access to.
My task is to build a web interface that will encapsulate some EXTENSIVE (200+ formulas) logic based in an Excel spreadsheet.
I will not be able to install any software on this server.
I do not want to recode all the formulas in C#.
What I would like is to use a standalone dll that will allow me to open an OpenXML formatted spreadsheet file, change the input cell values, and then extract the end values from cells containing formulas which have run on the new data.
Is there anything out there other than Excel interop (which requires Excel be installed) that will actually compute the formulas realtime?
Since you want to work with OpenXML files, you can use OpenXML SDK 2.0, which is available here: http://www.microsoft.com/download/en/details.aspx?id=5124. You should install it on your developer environment and it helps you to read and modify contents of OpenXML files in your .NET application.
I haven't tried to work with formulas using this SDK, but I suppose it's possible, however, it may require some work (like writing a parser) to recalculate the formulas with you program.
There is, however, a workaround for this, but I'm not sure if it's acceptable for you. You can make Excel reevaluate all the formulas itself when the file is opened by a user. You can find some information about it here: OpenXML SDK: Make Excel recalculate formula.
I also recommend you to use OpenXML SDK 2.0. Productivity Tool, which is a part of the SDK. It allows you to view the contents of an OpenXML file and even show you the c# code required to recreate it programmatically, so it can be really helpful.

Reading/Writing Excel sheet real time in C#

Is there any free or purchased library or any API which allows me to update excel sheet while it is opened also.
I'm not certain of the nature of your project, but perhaps you could create an Office Add-In? I've had some very good experiences with Add-In-Express: http://www.add-in-express.com/add-in-net/index.php
If just creating an add-in isn't going to work for your application, consider writing a plugin that your application can communicate with to do the work for you behind the scenes.
If you want your Excel spreadsheet to be updated in real time, you have to develop an RTD which can be queried by Excel itself. Please refers to Microsoft documentation for that. Add-In express provides you excellent simplified API to develop that, we are using them and we are very happy with that.
There is no tool that can do that since the file is locked by the operating system.
With COM you should be able to drive a workbook that has been opened by the user.

Exporting Listview in Visual Studio Into Microsoft Excel

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).

C# Best way to read a XLS (XLSX) file and populate a datagrid

What is the best (free or paid for) to read Excel files (XLS and XLSX) using C# and populate a datagrid, I would also like to have any changes made in the datagrid be written back to the file.
I should also add that it needs to be high performing as the datagrid can contain a significant number of rows (10,000+).
This would be used for a commercial application so it would need to be distributable.
This is a Windows Forms application.
I recommend databinding the datagrid to a dataset/datatable populated via the ADO.NET OleDb provider.
You'll find an example at Read from Excel using OleDb in a Windows Service?
I also found How To Use ADO with Excel Data from Visual Basic or VBA and How To Use ADOX with Excel Data from Visual Basic or VBA to be useful in knowing how to create a table (sheet) and access sheets and ranges.
It works very well for xls files. I haven't tried using it for xlsx.
SmartXLS for .Net
It support read/write xls/xlsx files and can import/export workbook datas to/from a datagrid.
You don't define whether you speak about web or fat client application.
You can use Open XML SDK 2.0 for Microsoft Office for reading XLSX file. (see http://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&displaylang=en and http://msdn.microsoft.com/en-us/library/cc850837(v=office.14).aspx for some examples and also on http://openxmldeveloper.org/default.aspx.)
You can display and allow to modify the content in a grid like jqGrid (see http://www.trirand.com/blog/?page_id=6) if you use a Web application. This grid is the best jQuery plugin which has a lot of different features and allow implement practical every scenario.
After all you can use Open XML SDK to save result in a modified XLSX file.
For xlsx :
http://msdn.microsoft.com/en-us/library/bb332058%28v=office.12%29.aspx
http://www.codeproject.com/KB/office/OpenXML.aspx

Categories

Resources