Insert Image on Excel using Open XML - excel

I am using this toolkit to write Excel.Every thing is fine with this,
but i am not getting how can i inset image and put style on some rows on my excel
i am using c#

I am using EPPlus for this specific task. It's a really nice and stable library.
EPPLus - Advanced Excel 2007 spreadsheets
And you may find allot of samples, including adding images and cell formatting, here

Related

Hidding comments by default for libreOffice?

I am generating a spreadsheet that users can fill data and upload again. And most column headers have comments with some minor rules (e.g. "Required").
The XLS files look great on Microsoft Excel and when imported on Google Docs. Where all the comments show up only on mouse over. But on LibreOffice, all the comments are visible from the start. Users can work around by selecting all cells and then view>comments. After that, the comments only show up when moused over, like on microsoft excel.
Is there any way to generate the XLS file in apache POI (XSS) in a way that the comments will be hidden in libreOffice too?

How to add multi-select dropdown in excel using poi

I have an list of Strings (A,B,C,D,E) and i have added this list to cell using range and data validity in libre office. but it only selects one value at a time. I want something like if i select first D and then C output should be like D,C multi-select. I have already studied all the questions on stack overflow but i haven't found anything. Thanks, in advance.
POI doesn't support multi select drop down.
You can follow the below link.
http://poi.apache.org/spreadsheet/quick-guide.html#Validation
As the provided link requires VBA scripting to do things, it is not possible to do this in POI currently as support for reading/adding VBA code is very limited. You could try to add it via the low-level API of POI, but would first find out where Excel stores the VBA code inside the .xlsx-file (it's actually a zip-file, so you can unzip it and take a look).
See the following for some pointers:
Macro support in POI
How to call a Macro from Apache POI library in Java?
How to call an Excel VBA Macro from Java Code?

datagrid as excel editor in c#

I have a requirement to display data from excel document in a C# win form datagrid. Add formula functionality of excel and apply in the datagrid value. When saving datagrid values to a excel value save same like excel file including formulaes.
Can any one help me how to do this one.
Is it can be doable through OpenXml or OleDB because I don't want to depend upon MS Office installation in client place.
Thanks in advance.
Sharma
this requirement of yours sounds like a project itself ! but I am sure this can get you started http://www.codeproject.com/Articles/17853/Implementing-an-Excel-like-formula-engine

Excel crashes and misdisplays files written using Apache POI (in the Excel 87-2003 .XLS format)

our Java EE applications writes large (>3000 rows, >300 columns) Excel files using Apache POI. We have implemented the customer's requirement that many (>500) of the cells in the written file have a partial text formatting, i.e. the text in one cell is partially red and bold, and partially black.
Apache POI does not complain when writing the files, and they can be opened, BUT Excel 97 misdisplays them: parts of the cells have the wrong font size, and cells with multiple font colors cannot be changed (altering the font size on them does not work).
Also, Excel 2010 complains that the file is insecure (when downloaded from the server), and both Excel 97 and Excel 2010 crash on the exported files frequently.
The previous version of the application used JExcelApi and did not write multiformatted text cells. The files generated by the server using the previos (JExcelApi-powered) version of the application do display normally in Office2010, without the security warning.
Did anyone come across these issues and if so, how can I fix them?
Also, did anyone figure out why setting AutoFilters fails to show up in Office 2010 in the specified, yet shows up in Excel 97 correctly (so it sometimes crashes or works just until one AutoFilter is selected?).
Finally, I have tried to roundtrip an Excel export of the older version of the application, and found that Apache POI reduces the file size by >35%, while breaking the file's contents - although no changes are applied (just reading the file into a HSSF Workbook and re-writing it into a ByteArrayOutputStream. Did anyone figure out how to prevent POI from altering the written file?
Thanks,
Michael
There's a lot of questions here, but it sounds like POI is outputting records that 97 is misinterpreting. There are significant differences between a 97' .xls and a 2003 .xls. The dialog behaving strangely is often a symptom of a malformed record. Excel 2010 has a binary file validator that it runs internally on any of the binary file format files (BIFF). It will pick up on any records that aren't to the BIFF specifications.
I'm not sure what's going on with the AutoFilters or the altering behavior.
If you're having a lot of trouble with POI, you may wish to check out OfficeWriter which does a pretty good job with 2010 validation and styles in general.
DISCLAIMER: I'm one of the engineers who wrote the latest version.
The root cause of our problem was traced to conditional formatting introduced in the excel template files. This resulted in the output file having conditional formatting.
We got rid of the conditional formatting and all is well now !
The problem manifests very severely when the users try to access the files over network.
Conditional formatting can be removed from excel.
Do ensure to remove the conditional formatting from all sheets / styles as well.

Export to Excel using ASP

At the time of exporting to excel using ASP. After converting a column in text format single quote is visible in the excel file. how to hide this automatically ?
You might be helped by setting the style of your cell to mso-number-format:"\#", but I'd have to see your code to know the exact problem.
I think you might find Styling Excel cells with mso-number-format and Generate Excel files in ASP Classic useful.
When you export to excel, you could juste make a table with cell, and put your value into double quote. Excel will read it correctly
Here's the library I use, to export data to Excel 2007 (.xlsx) files.
It lets you export any DataSet, DataTable or List<> directly into an Excel 2007 file, using one line of code.
It's completely free, and you can download the source code (and see how to use it) here:
http://www.mikesknowledgebase.com/pages/CSharp/ExportToExcel.htm

Resources