When adding conditional formatting to a sheet using c#
How do I set the IconSet being used?
Below isn't currently working. It gives me a set of default icons but not the ones I want.
Excel.IconSetCondition cfIconSet =
(Excel.IconSetCondition)excelWorksheet.get_Range(cellNumber, cellNumber)
.FormatConditions
.AddIconSetCondition();
cfIconSet.IconSet = Excel.XlIconSet.xl3Flags;
Solved
cfIconSet.IconSet = cfIconSet.IconSet(Excel.XlIconSet.xl3Flags);
Related
I have a function ApplyFormulas() that will obviously apply formulas like so
detailWs.Range(companyModel.RevenueFormulaRangeDollars).FormulaR1C1 = companyModel.RevenueFormulaDollars;
However Now I need to copy that range and paste it in the same spot so the values are real and not just formula references.
I am able to do this in VBA with excel interop but I am utilizing ClosedXML. Does anyone know of a way to do this? I tried CopyTo() but there is no paste special etc.
I also attempted
detailWs.Range(companyModel.NoChargeFormulaRangePercent).Value = detailWs.Range(companyModel.NoChargeFormulaRangePercent).Value;
but im getting a property or indexer cant be used because it lacks a getter but from what I can tell both have a get; set; property.
I've tried a couple for things and still not working..
var test = detailWs.Range(companyModel.NoChargeFormulaRangePercent).CellsUsed();
foreach(var c in test)
{
c.Value = c.Value.ToString();
}
Here's what I created a few months ago to copy all the formulas in one worksheet to another.
Note: I am having a problem where some formulas using a Name are not correctly copying the Name because something thinks the Name(i.e. =QF00) is a reference and will change it with AutoFill. Will update when I figure it out.
cx.IXLWorksheet out_buff
cx.IXLRange src_range
cx.IXLCells tRows = src_range.CellsUsed(x => x.FormulaA1.Length > 0);
foreach (cx.IXLCell v in tRows)
{
cell_address = v.Address.ToString();
out_buff.Range(cell_address).FormulaA1 = v.FormulaA1;
}
1) i am using SpreadsheetLight library and i like to know how could i set row's color red or yellow ?
2) also tell me how could i set color range wise say Range["A1:Z1"] ?
3) how to apply format cell range wise ?
sheet.Range[DataRangeCoordinate].NumberFormat = "#,##0.000;[Red](-#,##0.000);#,##0.000";
the above code is devexpress spreadsheet related. so how to do the same when working with SpreadsheetLight ?
4) how to iterate in all cell value with in For loop ?
when i am using dev express spreadsheet grid then i use below code to set back & fore color
sheet.Range["A1:Z1"].Font.Color = Color.IndianRed;
sheet.Range["A1:Z1"].Fill.BackgroundColor = Color.LightGray;
sheet.Range["A1:Z1"].Style.Font.Bold = true;
5) How to set column width for all column ?
6) How to set autofit all columns ?
7) i am getting error when i am trying to create CreateStyle
my code as follows
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Spreadsheet;
using SpreadsheetLight;
SLStyle style1 = sl.CreateStyle();
style.Fill.SetPattern(PatternValues.Solid, System.Drawing.Color.IndianRed, System.Drawing.Color.LightGray);
sl.SetCellStyle(1, 0, style1);
i have installed latest version of OpenXml from Nuget.
please help me with code sample. thanks
Did you check the developer documentation of spreadsheetlight?
They provide an example here: http://spreadsheetlight.com/downloads/samplecode/StyleRowColumnCell.cs
I am trying to find the style name that are applied to my table and based on that i have to apply the width to the table.
here is the code.
public void MakePageWidth(Word.Document document,bool Paragraphs = false)
{
float nleftIndent = document.Application.CentimetersToPoints(Constants.LEFT_INDENT);
document.Application.Selection.Paragraphs.LeftIndent = nleftIndent;
}
how to find the name of the style that r applied to my paragraph.
Object styleobject = document.Application.Selection.get_Style();
string stylename=((Word.Style)styleobject).NameLocal;
I have tried this.its working for me.
You can access the style and properties using the get_Style() function. This is a dynamic object, hence you dont get what are the properties available within it. However in the debug mode you can get all the properties of it. For example if you want to retrieve the style name you can use the following,
document.Application.Selection.get_Style().NameLocal;
Is it possible to add values to a CRM 2011's optionset via a C# application?
These MSDN article, provide the code and examples for working with Global Option Sets
http://msdn.microsoft.com/en-us/library/gg509056.aspx
http://msdn.microsoft.com/en-us/library/gg509023.aspx
If you want to convert your local to global, check this out:
If you want to create Local Option Sets (the example is in javascript, but the same requests exist in the C# library):
http://mileyja.blogspot.com/2011/03/working-with-optionset-values-in.html
Yes. You can set an option set value by:
OptionSetValue optionSet = new OptionSetValue();
optionSet.Value = 2; // optionset value is an integer
yourEntity["yourdropdown"] = optionSet;
I am reading Excel file using LinqToExcel:
var Excel = new ExcelQueryFactory(Filename);
Excel.databaseEngine = DatabaseEngine.Ace;
Excel.strictMapping = true;
I want to exclude certain columns, to prevent the strict mapping feature from throwing an exception for those columns.
What if you set StrictMapping to false? Will that work for you?