0

i need to create and download a excel sheet in c# asp.net. I used writing Range. because it is fast. but i need to format the excel sheet. According to a property(usercolor) of the user object, i need to color the row. but when writing to range how can i do that?

i am using this code to write
var startCell = (Range)sheet.Cells[2, 1]; var endCell = new object(); endCell = (Range)sheet.Cells[(usersList.Count + 2), noofcolums]; var writeRange = sheet.get_Range(startCell, endCell); writeRange.Value2 = data;

data is a TwoDimensionalObject. it is created by user object.

4 Answers 4

2

As an additional comment: Do NOT use Excel in a server inevironment. It is slow and Excel might spawn error-windows at any time, causing a hang. This cannot be circumvented in a clean way - even Microsoft agrees and does not support office in a server model. You might try epplus, a free reading / writing library for excel. It is fast , supports formatting and is way nicer to program than excel interop.

Sign up to request clarification or add additional context in comments.

3 Comments

but i need support 2003. epplus support 2007 excel
There are some other packages in the wild, please search stackoverflow for examples. Aspose cells could be good, but you have to pay for it. Using excel is probably a last ditch alternative... As a question: way do you have to support the old 2003 format?
it is my client requirement
0

To color any Row in Excel

oRange.get_Range("A1","X1").Interior.Color = System.Drawing.ColorTranslator.ToWin32(Color.Orange);

Hope it helps

1 Comment

thanks for your response. but i need to know how to get proper rows and only color them. Is there any way to querying according to object.
0

I could not find any way to use Object property to map with row color in range writing way. I need to write cell by cell. but it is very slow. So i used creating html file(html table) and convert it to excel document. it is not slow also. Thank you very much for all replies

Comments

0

please refer this Export HTML Table to Excel using ASP.NET

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.