Question

Narayana Reddy GundReddy on Tue, 17 Mar 2020 03:23:39


Dear all,

I have a requirement to apply the font and color to the excel cells in a row using DocumentFormat.OpenXml and have to do it programatically. I would like to have sample code examples or article(s) with regards to this. Please share your ideas and information. I appreciate your help and support. Thank you so much!


Narayana Reddy G

Replies

Ashidacchi on Tue, 17 Mar 2020 06:54:00


Hi,

I'd like to confirm:
1) What do you mean by "programatically"? Do you want to use Excel VBA or other programming language (e.g. VB.NET, C#)?
2) Could you share a sample OpenXml file via cloud storage (e.g. OneDrive, Dropbox)?

Regards,

Narayana Reddy GundReddy on Tue, 17 Mar 2020 09:31:39


Dear Ashidachhi,

Thank you for your reply. I want to use C# language to apply styling on excel cell. I requested any sample programming examples for styling excel cell. If you have any articles explaining to achieve the excel cell styling through c# programming, please share those links here. Thank you so much for your support!

Ashidacchi on Tue, 17 Mar 2020 09:58:34


Hi,

Thank you for your explanation. 
Let me ask one more question.  In your first post, you wrote "DocumentFormat.OpenXml".  And in the 2nd, you said "excel cell". 
Can I understand that you want to style cell in Excel worksheet with C#?

Regards,

Narayana Reddy GundReddy on Tue, 17 Mar 2020 10:13:19


Dear Ashidacchi,

Yes, I want to style cell in the Excel worksheet, but I have to make use of this class DocumentFormat.OpenXml.Spreadsheet. If you've any information pertaining to this, please share. Thank you so much for your support.

Ashidacchi on Tue, 17 Mar 2020 10:39:19


Hi,

I've found some examples.

Excel styles and formatting in C# and VB.NET
https://www.gemboxsoftware.com/spreadsheet/examples/c-sharp-vb-net-excel-style-formatting/202

Formatting Excel Sheet using C#. The Style apply to all cells not to one cell
https://stackoverflow.com/questions/42500606/formatting-excel-sheet-using-c-the-style-apply-to-all-cells-not-to-one-cell

I hope these articles will be helpful.

Regards

Ashidacchi on Tue, 17 Mar 2020 10:49:32


Hello Narayana Reddy G,

Let me ask one more question.
Why is "DocumentFormat.OpenXml.Spreadsheet" needed?
Can't we style cells in the Excel worksheet with "Microsoft.Office.Interop.Excel"?

Regards,

Narayana Reddy GundReddy on Tue, 17 Mar 2020 11:01:12


Dear Ashidachhi,

We may have to install excel software on the server, if we make use of "Microsoft.Office.Interop.Excel". This is the reason I am advised to make use of DocumentFormat.OpenXml.Spreadsheet. Thank you for your support and time.

Ashidacchi on Tue, 17 Mar 2020 11:41:18


Hi Narayana Reddy G,

We may have to install excel software on the server, if we make use of "Microsoft.Office.Interop.Excel". This is the reason I am advised to make use of DocumentFormat.OpenXml.Spreadsheet.


If I understand what you wrote correctly, I suppose you have no need to install Excel software on the server.
In my environment (Win.10 Pro 64-bit, Excel 2016 32-bit), "Microsoft.Office.Interop.Excel.dll" is in a folder
1) "C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\"
2) "C:\Program Files (x86)\Microsoft Office\root\Office16\DCF"

I suppose it would exist in PCs which can execute Excel and C# program, and your client PCs can execute your C# application without Excel software on the server.

Regards,

Narayana Reddy GundReddy on Tue, 17 Mar 2020 17:43:53


Dear Ashidacchi,

Thank you for sharing the information. As of now, I am advised to make use of "DocumentFormat.OpenXml.Spreadsheet" because already code is written creating new excel file using this class. If I do not find any solution then I will suggest them Microsoft.Office.Interop.Excel.dll. Thank you again for your support and time.