i created code for above by using Visual studio13 bt there is an error
here is C# code :-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Excel;
using Windows.UI.Popups;
using Syncfusion.XlsIO;
using System.Collections;
using System.ComponentModel.DataAnnotations.Schema;
using Windows.Storage.Pickers;
using Windows.Storage;
using System.ComponentModel;
using ExcelLibrary.SpreadSheet;
using ExcelLibrary.CompoundDocumentFormat;
//using System.Windows.Forms.ComponentModel.Com2Interop;
//using System.Windows.Forms.Control;
//using System.Windows.Input;
namespace CreateExcel.View
{
class ExcelSheet
{
public async void createExcelSheet()
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
//application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
savePicker.SuggestedFileName = "CreateSpreadsheet";
savePicker.FileTypeChoices.Add("Excel Files", new List() { ".xlsx" });
StorageFile storageFile = await savePicker.PickSaveFileAsync();
// Saves changes to the specified storage file.
//await workbook.SaveAs(StorageFolder");
workbook.Close();
excelEngine.Dispose();
}
}
}
and Here is Xaml Code:- x:Class="CreateExcel.View.Trigger"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CreateExcel.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
and im getting an error i.e.
Microsoft.Windows.UI.Xaml.Common.targets(286,5): Xaml Internal Error error WMC9999: Cannot find type System.ComponentModel.LicenseProvider in module System.dll.
my email id -: "[email protected]"
please send me solution
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
alice yangPosted Feb 25, 2016, 1:37 AM
Shubham KumarPosted Feb 25, 2016, 12:33 AM
public void GetExcel(DataTable Dt)
{
Microsoft.Office.Interop.Excel.Application excel = null;
Microsoft.Office.Interop.Excel.Workbook wb = null;
object missing = Type.Missing;
Microsoft.Office.Interop.Excel.Worksheet ws = null;
Microsoft.Office.Interop.Excel.Range rng = null;
try
{
excel = new Microsoft.Office.Interop.Excel.Application();
wb = excel.Workbooks.Add();
ws = (Microsoft.Office.Interop.Excel.Worksheet)wb.ActiveSheet;
for (int Idx = 0; Idx < Dt.Columns.Count; Idx++)
{
ws.Range["A1"].Offset[0, Idx].Value = Dt.Columns[Idx].ColumnName;
}
for (int Idx = 0; Idx < Dt.Rows.Count; Idx++)
{
ws.Range["A2"].Offset[Idx].Resize[1, Dt.Columns.Count].Value =
Dt.Rows[Idx].ItemArray;
}
excel.Visible = true;
wb.Activate();
}
catch (COMException ex)
{
MessageBox.Show("Error accessing Excel: " + ex.ToString());
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.ToString());
}
}
Chandu KumawatPosted Feb 25, 2016, 12:29 AM