Download LiteExcel from codeplex ( my open source silverlight library for manipulating MS excel without COM interaction).
Add reference of “Lite.Library.dll” and “Lite.ExcelLibrary” to your Silverlight project.
Refere “Lite.ExcelLibrary.SpreadSheet” on the top of your Silverlight page.
using Lite.ExcelLibrary.SpreadSheet;
Writing an excel file
// open file dialog to select an export file.
SaveFileDialog sDialog = new SaveFileDialog(); sDialog.Filter = "Excel Files(*.xls)|*.xls"; if (sDialog.ShowDialog() == true) { // create an instance of excel workbook Workbook workbook = new Workbook(); // create a worksheet object Worksheet worksheet = new Worksheet("Friends"); // write data in worksheet cells
worksheet.Cells[0, 0] = new Cell("Column1"); worksheet.Cells[0, 1] = new Cell("Column2"); worksheet.Cells[0, 2] = new Cell("Column3"); worksheet.Cells[1, 0] = new Cell("string value"); worksheet.Cells[1, 1] = new Cell(478574.5, "#,###.00"); worksheet.Cells[1, 2] = new Cell(4);
workbook.Worksheets.Add(worksheet);
Stream sFile = sDialog.OpenFile();
// save method needs a stream object to write an excel file.
workbook.Save(sFile);
}
Hi again
ReplyDeletePlease I need more functionality for formatting the cells in Excel.
How can I do with your library?
For instance: font in bold.
Thanks
Hi, Yes it would be great if we could manipulate the Cells style.
ReplyDeleteMuhammad it is possible with yours DLLs?.
Thanks.
Great work abubakar
ReplyDeleteThanks man, you resolve a lot of my problems, thanks soo muth.
ReplyDeleteHi, I also wonder if we are able to merge cells and rows.
ReplyDeleteThanks...
The source doesn't compile (can't even open the project), when I add the binary dll to a project, it says assembly system.windows not referenced, when I add system.windows.presentation, it says exception in ms.internal.jolt...
ReplyDeleteI correct myself:
ReplyDeleteCopy all source files into a new project and add references to:
PresentationCore
PresentationFramwork
WindowsBase
System.Xaml
Then it works.
One still needs to comment out
TranslateImageToBytes in ImageTranslator.cs
Now it works in a console application :-))
Added an issue on CodePlex.
ReplyDeleteSee here: http://excellite.codeplex.com/workitem/175
@Anonymous hey don`t complain, it`s a silverlight project!
ReplyDeleteThanks a lot for this! I used it and it works wonderfully, just need to try catch more around the book.load and book.save in case of problems. :)
How can I change the cell size, border, format?
ReplyDeletePlease, post examples.
Thanks
I'm using silverlight3 and it's giving build time error when referencing excellite classes.... will this work only on silver light 4?
ReplyDeleteHello,
ReplyDeleteyour exportet Excel Workbook has always 49 empty Rows at the End of the File, do you know why and how to fix this?
The sheet is instantly saved by OpenFile, is there an option to save the Excel to a stream, that I could do with the data what I want?
ReplyDeleteIts not working..
ReplyDeletei am using Office 2007,there is no data's in excel file after clicking the export button
How can I change the cell size, border, format?
ReplyDeletePlease, post examples.
How can I change the cell size, border, format?
ReplyDeletePlease, post examples.
Cell size border, color is not working.
ReplyDeleteCellStyle class is defined. But after meshing with it for two hours I realized that its dummy. Total waste..
ReplyDeleteIs it possible to do indentation of cells and/or grouping? I'm porting some Excel export code from an ASP.Net app that uses the Infragistics Excel library to SL4 and want to get the same look in grouped grids if possible.
ReplyDeleteCheers,
Paul.
Hi,
ReplyDeleteIt is only working for .xls files? How can I use it for .xlsx? When I use excel 2007 it says it couldn't open the document. Please help me.
functionality for formatting the cells in Excel.
ReplyDeletePlz Read this
http://humrahimcs.wordpress.com/2012/01/26/telerik-radgridview-export-to-excel-with-format/
Hi,
ReplyDeleteI was trying to export multiple pictures in single worksheet and excel cannot open the resulting file.
Can you help,
Thanks,
Does this now work with Excel 2007-2010? I read on codeplex that it was not as yet /
ReplyDeleteHi,
ReplyDeleteHow can i export multiple files in multiple worksheet?
Any help would be appreciated.
Thanks.
Gracias!!!!
ReplyDeleteHi,
ReplyDeleteHow can I change the cell size, border, format and color?
Thanks.
What is the way if someone want to create excel from an ObservableCollection of custom class type ??
ReplyDeleteHi, How to set font style for header ?
ReplyDeletegood work Abubakar. you are a professional. use use https://zetexcel.com/ excel library. what you think about it. so far it works great for me.
ReplyDelete