Aspose.Cells Cell Styles - applying styles doesn't work

Hi,I'm using Aspose.Cells v7.1.2.0 (3/12/2012) / Visual Studio 2008 ASP.Net / VB.NetMy code is fairly simple. I have a template xlsx file with headers that I load / rename and populate with data from a data reader.Based on values from the data reader I want to set the background color to either light green or gray. I've tried implementaions of every example I could find but to no avail.

Dim oWorkbook As Workbook = New Workbook(sOutputFileName)

Dim oWorksheet As Worksheet = oWorkbook.Worksheets("Users")

Dim oStyleNo = oWorkbook.Styles(oWorkbook.Styles.Add)


Dim oStyleYes = oWorkbook.Styles(oWorkbook.Styles.Add)

oStyleNo.BackgroundColor = System.Drawing.Color.Gray


oStyleNo.Pattern = BackgroundType.Solid

oStyleYes.BackgroundColor = System.Drawing.Color.LightGreen


oStyleYes.Pattern = BackgroundType.SolidoWorksheet.Cells(iRow, 11).PutValue(drUserAudit(

“IsAssetAnalyst”))


oWorksheet.Cells(iRow, 11).SetStyle(oStyleYes)–

Above doesn’t work

----

oStyle = oWorksheet.Cells(iRow, 0).GetStyle()

oStyle.ForegroundColor = System.Drawing.Color.Yellow

oStyle.Pattern = BackgroundType.Solid

oWorksheet.Cells(iRow, 0).SetStyle(oStyle)

oStyle = oWorksheet.Cells(iRow, 0).GetStyle()

oStyle.ForegroundColor = System.Drawing.Color.Yellow

oStyle.Pattern = BackgroundType.Solid

oWorksheet.Cells(iRow, 0).SetStyle(oStyle)

---

Above doesn't work.

----

I could really use some help with this.

Thanks,

Bill

Hi,

Please download and use the latest version:
Aspose.Cells
for .NET v7.1.2.5
. It is working fine.

Please see the code below and its output.

As you can see, it renders the cell A1 with Gray fill as shown in screenshot. Please see the output file generated by this code which I have attached.

VB.NET


Dim oWorkbook As Workbook = New Workbook()


Dim oWorksheet As Worksheet = oWorkbook.Worksheets(0)


Dim oStyleNo = oWorkbook.Styles(oWorkbook.Styles.Add)


Dim oStyleYes = oWorkbook.CreateStyle()


oStyleYes.Pattern = BackgroundType.Solid


oStyleYes.ForegroundColor = System.Drawing.Color.Gray


'oStyleYes.BackgroundColor = System.Drawing.Color.LightGreen


Dim oYourCell As Cell = oWorksheet.Cells(“A1”)


oYourCell.SetStyle(oStyleYes)


oYourCell.PutValue(“sample”)


oWorkbook.Save(“F:\Shak-Data-RW\Downloads\output.xlsx”)


Screenshot:

Wow,

thanks for the quick response.

I will download and try the sample you provided. Thanks for taking the time to write it up for me.

I will let you know the outcome.

One comment that I do have, is that when I first was implementing this and it didn't work. I did download the latest Aspose.Net total off the download page. I'm surprised that that did not include the latest Aspose.cells. I was sure that would include the latest of all your .Net products.

Cheers,

Bill

Hi,

We release minor releases from time to time, so Aspose.Total is not always updated with the latest releases.

At the end of month, we publish major releases and update Aspose.Total.

Please always check for latest version of Aspose.Cells from the following link.


Aspose.Cells for .NET -
Files

Sorry for inconvenience caused.

Understood about the updates Shakeel.

Regarding my implementation using the latest Aspose.Cells; it appears to set the foreground as I had wanted to do.

A nuance of my application is that once it generates the excel file and saves it; it downloads it to the user. The user may save or open via the standars dialog.

If open is selected the excel appears to be completely blank and non selectable. I did not have this problem before implementing the styles.

I use a lot of this type of excel generation / download to the client and for the most part the user selects to Open prior to download. Until now I haven't experienced any issue.

Is there an additional step that I need to take when implementing styles?

I would like to leverage this functionality; is there any advice you can provide.

Thanks,

bill

Hi,

Please provide screenshots with red circles or marks illustrating your problem. You can create them using Ms-Paint.

It will help us understand the problem you are facing and we will be able to give you advice or workaround better.

Thanks for your help.


Hi

I've pulled out my code into a small project to demonstrate what i'm doing and what the output is. I've tested with / withou styles (originally i thought the implementation of the styles was creating the problem), but unfortunately i'm getting the same 'blank' page problem in both scenarios.

In the zip file is a bmp of the blank page that appears when 'Open' is selected after clicking the Icon on my page.

It's a simple program / requires no database required.

I should mention, that with the exception of trying to apply styles, I've used this logic over half a dozen times in production without issue - using previous versions of Aspose.Cells.

Under the circumstances, there's no way I could possibly promote this version of Aspose.cells to my production environment.

I'm running this on a windows 7 professional pc with SP 1

visual studio 2008 w / .Net Framework 3.5 SP 1

MS office 2010 Professional.

Please let me know if you have any trouble running the sample.

The program on load, copies a template file (Temp/Template.xlsx) to Temp/Template.xlsx.

It then opens the file and populates it with some random text in each of the columns.

After the page loads, the user clicks on the Excel icon which then streams the file to the user; where the user is prompted to save / open.

On open is where a Browser page appears, which looks empty but actually as excel embedded.

If you mouse over / clicking certan areas of the excel will become visble, but none of the data or major parts.

You can view the actual physical file in the Temp directory.

Thanks for your help,

bill

I did some additional tests on the test program that i wrote.

It appears if i publish the site to my local host, the excel does open without issue. I'll play with that a little bit more to see if I can figure out why it doesn't work in the environment.

Bill

Hi,

Probably, your problem is because of Trust Level and you are running your application in Medium Trust.

Please try to run it in Full Trust mode and see if it works for you.

Please also keep drilling it down and let me know your feedback. Thank you.

Hello,

Originally I thought that this might be a trust issue but the trust settings have not changed on my development machine. And other excel downloads work fine.

To test this, I decided to load the previous version of my project using the previous version of Aspose.cells that I was using and I ran one of the regular output / download to excel reports that I was running without issue.

I'm able to run that report with both the old and newer version of aspose.

This is a perplexing problem.

I will let you know what I find.

Hi,

It’s good to know that older and newer version are now running fine.

If you find any other problem, please let us know. We will be glad to assist.