Setting Password property appears to not password protect when saving to Excel2007Xlsx format

When I set the Password property on the Workbook object and save the Workbook. Then browse to the directory I saved the Workbook I am not prompted to enter the Password when opening the file.

Is this currently not supported in the new XLXS format?

It does work under the Excel2003, but then all my conditional formatting does not work correctly. And I need to have conditional formatting and a password protected workbook.

Any help would be appreciated.


This message was posted using Page2Forum from Password Property - Aspose.Cells for .NET and Java

Hi,

I 'm afraid the feature (password protected worbooks in Excel 2007 .xlsx files) is not supported currently, we will support it soon.

For conditional formatting issue, could you elaborate it more and provide us the template file with sample code to reproduce the issue. We will check it soon.

Thank you.

Code snippet for applying conditional formatting. This is done after all the data has been written to the file.

private void ApplyConditionalFormating(Aspose.Cells.Worksheet ws, int rowsToAdd)

{

Aspose.Cells.FormatConditions fcs = ws.ConditionalFormattings[ws.ConditionalFormattings.Add()];

CellArea ca = new CellArea();

ca.StartRow = 6;

ca.EndRow = 5 + rowsToAdd;

ca.StartColumn = 0;

ca.EndColumn = 0;

fcs.AddArea(ca);

Aspose.Cells.FormatCondition fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.LessThan, "0.00", null)];

fc.Style.BackgroundColor = Color.FromArgb(255, 206, 206);

fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "0.00", "0.039")];

fc.Style.BackgroundColor = Color.LightYellow;

fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.GreaterOrEqual, "0.04", null)];

fc.Style.BackgroundColor = Color.FromArgb(206,255,206);

}

In the Output.xls file starting at row 7 in the 1st column you will see numbers entered in. Click on cell A7 and then view the Conditional Formatting and you will see the format, but there are no background colors set. The background colors is the only thing that I am missing.

Thanks for your help.

Hi,

Thanks for considering Aspose.

Well, the color(s) your are applying might not be present in the Standard Color Palette, so you have to add it first into the palette before setting it as a background color for conditional formattings. Since the Excel color palette has only 56 colors (0-55 indexed) on it, so if a color is not there, you will add the color to the palette replacing any existing color on a specified index position.

I think you may add some extra lines of code for your code:

e.g..,

........

Workbook workbook = new Workbook();

................

workbook.ChangePalette(Color.LightYellow,55);

workbook.ChangePalette(Color.FromArgb(255, 206, 206), 54);

workbook.ChangePalette(Color.FromArgb(206,255,206), 53);

.........

private void ApplyConditionalFormating(Aspose.Cells.Worksheet ws, int rowsToAdd)

{

Aspose.Cells.FormatConditions fcs = ws.ConditionalFormattings[ws.ConditionalFormattings.Add()];

CellArea ca = new CellArea();

ca.StartRow = 6;

ca.EndRow = 5 + rowsToAdd;

ca.StartColumn = 0;

ca.EndColumn = 0;

fcs.AddArea(ca);

Aspose.Cells.FormatCondition fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.LessThan, "0.00", null)];

fc.Style.BackgroundColor = Color.FromArgb(255, 206, 206);

fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.Between, "0.00", "0.039")];

fc.Style.BackgroundColor = Color.LightYellow;

fc = fcs[fcs.AddCondition(FormatConditionType.CellValue, OperatorType.GreaterOrEqual, "0.04", null)];

fc.Style.BackgroundColor = Color.FromArgb(206,255,206);

}

Thank you.

That was what I was missing. Thanks for your help.

Hi,

Please try this fix.

We have supported to set the password for Excel2007 xlsx and read the protected file.