Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: running MATCH formula from NPOI help

$
0
0
Good day, below is some code that I am trying to run. I realized my issue only happens when I have a 0 in for match but if I change it to 1 or -1 it works. It doesnt seem to be reconizing the 0, how do I fix this?

I tried another route by taking my data and moving it to the right hand of what I need and using a vlookup but the VLookup
sheet1.CreateRow(row + firstrow).CreateCell(19).SetCellFormula("VLOOKUP(" + j + "," + lookuprangess + "," + 2 + "," + "FALSE" + ")");  
gives the error
((NPOI.HSSF.UserModel.HSSFSheet)sheet1).IsAutoTabColor '((NPOI.HSSF.UserModel.HSSFSheet)sheet1).IsAutoTabColor' threw an exception of type 'System.NullReferenceException'
for (int row = 1; row <= 4; row++)
{
sheet1.CreateRow(row + firstrow + 1).CreateCell(15).SetCellFormula("LARGE(" + cellsranges + "," + row + ")");
HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);

double j = sheet1.GetRow(row + firstrow + 1).GetCell(15).NumericCellValue;

sheet1.CreateRow(row + firstrow + 1).CreateCell(16).SetCellFormula("MATCH(" + j + "," + cellsranges + ", " + 0 + ")");
HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);

double k = sheet1.GetRow(row + firstrow + 1).GetCell(16).NumericCellValue;

sheet1.CreateRow(row + firstrow + 1).CreateCell(17).SetCellFormula("INDEX(" + statesranges + "," + k + "," + 1 + ")");
HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);

string stateperc = sheet1.GetRow(row + firstrow+1).GetCell(17).StringCellValue + "-" + j.ToString();

MessageBox.Show(stateperc);
}
I am new to this so sorry if it is simple!

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>