Free Support Forum - aspose.com

Does Aspose.cells has support for UserInterfaceOnly option for sheet protection

Hi Aspose Team,

I have been working on the small module regarding the security purpose. In that i could see an option to protect the userinterface only and the macros will run. I have been searching for a long time in Aspose to achieve the same behavior. Is that possible to acheive throught any combinations. If so can you send me the code snippet.

This is an equivalent VBA code.

Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Protect Password:="Secret", _
UserInterFaceOnly:=True

Online resource code:

http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet.protect(v=VS.100).aspx

Thanks,

Lokesh

Hi,

You should refer to this document to implement advance protection.

Advanced Protection Settings since Excel XP

If your problem is still not resolved, then please attach your source and final workbooks which you can create manually in Aspose.Cells. We will look into it and if it is a new feature we will log it and implement in our coming releases.

Hi Lokesh,


Thank you for providing us the online documentation link.
Unfortunately, at the moment we do not support this feature through Aspose.Cells API. But we can log it as a “Required Feature” in our tracking system and check the feasibility for it’s implementation.
Please share with us a template / sample excel file showing the behavior you required.

Hi Babar,

Thanks for replying back.

I want to clarify one thing. Are you providing support for manipulating or writing the macros to the existing sheet.

-Lokesh

Hi,

Thanks for your question.

I am afraid, it is not in our plan to support writing/manipulating macros in newer/existing workbook/worksheets in near future.

Hi ,

Thanks for the update.

I have another clarification. Do you have support for converting the workbook as a stream and saving back the stream to workbook. Can you send me the sample.

-Lokesh

Hi,


Yes. Aspose.Cells support saving the workbook into Memory Stream. Below is the sample code you required,

C# Sample Code:

var result = new System.IO.MemoryStream();

Workbook workbook = new Workbook(“C:\temp\in.xls”);

workbook.Save(result, Aspose.Cells.SaveFormat.Excel97To2003);

var ofs = System.IO.File.OpenWrite(“C:\temp\out.xls”);

result.WriteTo(ofs);

ofs.Close();

Hi ,

Thats great!. Thanks for the quick reply.

Final one more thing i want to know is that possible to save the workbook as HTML but in the form of stream. I have tried the below code to save the workbook to stream and the save format as HTML. But i hope only the active sheet gets converted. Can you let me know how the whole workbook can be saved as a stream.

var stream = new MemoryStream();

Workbook book = new Workbook(@"../../Book1.xlsx");

book.Save(stream, SaveFormat.Html);

var ofs = System.IO.File.OpenWrite("out.html");

stream.WriteTo(ofs);

stream.Close();

-Lokesh

Hi,


Thank you for pointing this out.
I have noticed the same, when workbook is exported out to HTML through memory stream, only active worksheet gets rendered in HTML. I have logged a Ticket for this issue under ID CELLSNET-27340. Soon we will look into it.
Below is my source code and attached are the output files.

C#

var wb = new Workbook(“c:\temp\pivottableA.xls”);

var saveOptionsCell = new HtmlSaveOptions(SaveFormat.Html);

saveOptionsCell.IsExpImageToTempDir = true;

saveOptionsCell.ExportActiveWorksheetOnly = false;

wb.Save(“C:\temp\testA.html”, saveOptionsCell);

var ms = new System.IO.MemoryStream();

wb.Save(ms, saveOptionsCell);

var ofs = System.IO.File.OpenWrite(“c:\temp\testB.html”);

ms.WriteTo(ofs);

ofs.Flush();

ofs.Close();