I see that it’s using SUMIFS which can take multiple parameter as a where clause and it’s referring to dropdown cell. So it looks easy to create a chart on I see that tables have really complicated formula. Can we simplified it?
Hi,
Thanks for your posting and using Aspose.Cells.
You will be able to understand your formulas after some trial and error methods and playing with them.
You can use the following MS-Excel features.
- Find Options
- Show Formulas
- Evaluate Formula
The third one i.e Evaluate Formula is most important. It will help you understand how your formulas are being evaluated and how you can simplify them. I have attached the screenshots for your reference.
There are two other useful features which will be helpful for you.
- Trace Precedents (It will tell you the parent cells of your formulas)
- Trace Dependents (It will tell you the child cells of your current cell or formula)
Please see this article for your reference.
( Display the relationships between formulas and cells - Microsoft Support )
Hi,
To resolve my issue as mentioned earlier, I am creating multiple sheet and put it together in workbook. And while creating multiple worksheet, I am adding drowdown in each sheet to keep all sheets consistent.
here is my code for it.
int columnIndex = workbook.Worksheets.GetRangeByName(“MyRange”).FirstColumn;
workbook.Worksheets[0].Cells.HideColumn(columnIndex);
var comboBox = workbook.Worksheets[0].Shapes.AddComboBox(5, 0, 5, 0, 25, 250);
comboBox.InputRange = “=MyRange”;
comboBox.LinkedCell = “=A6”;
comboBox.SelectedIndex = arry.IndexOf(item);
comboBox.Name = “ddlName”;
Cell cell = workbook.Worksheets[0].Cells[“A6”];
Style style = cell.GetStyle();
style.Font.Color = Color.AliceBlue;
cell.SetStyle(style);
Now I need to write a VBA or macro code to activate sheet based on dropdown selection and my sheet names are same as dropdown values.
I am trying like this but it’s not working. This code is also in for loop to create macro on each sheet.
Can you give me some suggestion also I am attaching an excel with this one?
System.Text.StringBuilder sb;
// Aspose.Cells.Vba.VbaModule xlModule;
sb = new System.Text.StringBuilder();
//build string with module code
sb.Append(“Sub ddlName_Change()” + “\n”);
sb.Append(“Dim dd As DropDown” + “\n”);
sb.Append("Set dd = " + workbook.Worksheets[0].Name + “.Shapes(“ddlName”).OLEFormat.Object” + “\n”);
sb.Append(“Sheets(dd.List(dd.ListIndex)).Activate” + “\n”);
sb.Append(“End Sub”);
int idx = workbook.VbaProject.Modules.Add(workbook.Worksheets[0]);
Aspose.Cells.Vba.VbaModule module = workbook.VbaProject.Modules[idx];
//add the cmbbox macro to the spreadsheet
module.Codes = sb.ToString();
Hi,
Thanks a lot. It worked for me.
I am facing one more issue is that when I am looping through I am rendering report which give me a byte[]. So I need to create a workbook with different worksheets but I see that I can’t write a bytes to worksheet. Every time I need to create a workbook and after that I need to merge all workbooks together. Is there any way that initially I create a n empty workbook and after that in for loop I will add worksheet with bytes written to it.
Here is my code in for loop.
using (var ms = new MemoryStream())
{
ms.Write(bytes, 0, bytes.Length);
ms.Position = 0;
var workbook = new Workbook(ms);
workbookList.Add(workbook);
}
Hi,
Thanks for your quick reply.
My question is that , I am rendering report in for loop with all filtered dataset, which returns me bytes[] . So is it possible that I can write this bytes in excel worksheet . So At end of for loop I will have only one workbook with different sheets.
Currently I don’t see any methods which writes bytes[] to worksheet, I have to create workbook every time and after for loop completion , I need to merge or copy it as you suggested.
But I want to do like this way.
create a workbook outside for loop.
In for loop add new worksheet every time and writes byte[] in worksheet. So I don’t have to do copy or merge.
Hi Saurabh,