Hi Team ,
My requirement would be to disable the Copy Option in an Excel sheet Using Aspose Cells for .net . I have tried the following Options using Code
Worksheet sheet = wBook.Worksheets[wBook.Worksheets.ActiveSheetIndex];
Style style;
StyleFlag flag = new StyleFlag();
for (int i = 0; i < 255; i++)
{
style = sheet.Cells.Columns[i].Style;
style.IsLocked=true;
flag.Locked=true;
// Get style of the column
sheet.Cells.Columns[(byte)i].ApplyStyle(style,flag);
}
Aspose.Cells.Protection protection = sheet.Protection;
sheet.Protect(ProtectionType.All);
wBook.Save(@"C:\Test.xls");
The above Piece of Code Only disables editing Option But I can Copy the contents from it ,Please let me Know how can I disable Copying using Aspose Methods?
Hi Amjad,
Thanks for Reply yes we were not able to disable Copy Option in Excel Manually ,However our intention was not to Copy Contents from Excel Sheet Generated By Aspose,
The following Piece of Code was used
Worksheet sheet = wBook.Worksheets[0];
sheet.Protect(ProtectionType.All);
sheet.Protection.AllowSelectingLockedCell = false;
sheet.Protection.AllowSelectingUnlockedCell = false;
sheet.Protection.Password = “Ns@CRTY78”;
wBook.Save(saveStream, SaveFormat.Xlsx);
output =saveStream.ToArray();
excelFileName = ExcelFileName;
excelFileName = ExcelFileName.Replace(".xls",("." + extension));
Now the Problem is that Alignment of Charts (Getting Expanded) and Table values aligment is Changed After Applying Protection Properties ,Can you review the attachment and Suggest necessary Changes .The Aspose version of Dll used is 5.1.2.0
Thanks for your Suggestion ,We tried with Latest Version of Dll 8.6.3.0 FROM folder structure
Aspose.Cells_8.6.3\net3.5
We are receiving the Following error while Compiling the dll,Kindy help on this issue
SGEN : error : Could not load file or assembly ‘file:///C:\lib\Binaries\Aspose.Cells.DLL’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
License Version is 3.0 and Subscription expiry is
20160901
Hi,
I think it looks like a compatibility issue with your target .NET framework (in your project) that you are using. Please make sure that you are loading/referencing correct product binaries. Please note Aspose.Cells.Dll assembly from net2.0 folder can be used for 2.0, 3.0, 3.5 and 4.0 etc. .NET frameworks (it is backward compatible to work with any regular .NET framework versions >= 2.0), so you may use .NET 2.0 assembly of Aspose.Cells with your regular .NET frameworks in your project. Also, if your application’s target platform is set as .NET Framework 4.0 or greater, you may also set referencing to Aspose.Cells.dll from net4.0 folder present @ your installation folder.
Hope, this helps a bit.
Thank you.
Thanks Amjad ,Now Excel Aligment is fine and required Functionality is also achieved using Latest Aspose
Hi,
Good to know that your issue is sorted out by the latest version/fix. Feel free to contact us if you have further queries or issue, we will be happy to assist you soon.
Thank you.
Hi Team,
I have attached a report from the protected sheet where it is written as Market Commentary ,Sector Commentary if you click on it Width of region would expand and show the exact Lines in it ,But after Protecting whole sheet expansion of the commentary region is not Possible ,Is there any way using Aspose dll to restrict the protection in Specified regions ?
Thanks Amjad we were able to protect only specific rows as suggested in the previous reply.
Could you please assist us in fixing /removing the Overlapping text Boxes as attached in the report .
Here is the piece of Code of used for Creating Text Boxes using Latest version of Aspose
private static void CreateCommentaryTextboxes(Workbook workbook)
{
FindOptions findOptions = new FindOptions();
findOptions.LookAtType = LookAtType.Contains;
findOptions.CaseSensitive = false;
foreach (Worksheet sheet in workbook.Worksheets)
{
Cell cell = sheet.Cells.Find("##Commentary##", null,findOptions);
while (cell != null)
{
string commentaryblock = cell.Value.ToString();
string[] separators = new string[] { “##” };
string[] parts = commentaryblock.Split(separators, StringSplitOptions.None);
int top = cell.Row;
int left = cell.Column;
int height = Convert.ToInt32(parts[2]);
int width = Convert.ToInt32(parts[3]);
string text = parts[4];
int box = sheet.TextBoxes.Add(top, left, height, width);
Style style;
style = cell.GetStyle();
sheet.TextBoxes[box].Font.Color = style.Font.Color; cell.GetStyle();
sheet.TextBoxes[box].Font.Name = style.Font.Name;
sheet.TextBoxes[box].Font.IsBold = style.Font.IsBold;
sheet.TextBoxes[box].Font.IsItalic = style.Font.IsItalic;
sheet.TextBoxes[box].Font.Size = style.Font.Size;
sheet.TextBoxes[box].Placement = PlacementType.FreeFloating;
sheet.TextBoxes[box].IsTextWrapped = true;
sheet.TextBoxes[box].LineFormat.IsVisible = false;
sheet.TextBoxes[box].TextFrame.AutoSize =true;
sheet.TextBoxes[box].Text = text;
sheet.Cells.ClearContents(cell.Row, cell.Column, cell.Row, cell.Column);
cell = sheet.Cells.Find("##Commentary##", cell,findOptions);
}
}
Hi Dharshan,
Thank you for writing back.
I have checked your code snippet and the spreadsheet, however, I believe the spreadsheet is the output to the process whereas we require the input spreadsheet to successfully execute your provide code in order to find out the problem cause. Please be kind enough to share the input spreadsheet for investigation.
That said, we also request you to please create a new thread with appropriate title for every distinct problem you encounter with Aspose APIs. This will simply help us track your requests more efficiently.