Good afternoon . Just creating a small algorithm to count the number of matched values within 2 columns and think i may follow a longer path than needed so just thought that might be a smoother way in Aspose to do that for sure. My code until now (also provided a one page document to aid you visualise the subtask to accomplish)
int maxRow = cellsApiVal.MaxDataRow;
CellArea areaApivalues = CellArea.CreateCellArea(1, 1, maxRow, 1);
Range rngApiId = cellsApiReport.CreateRange(“B6”, “B58”);
// Algorithm to Lookup Col B from API Report ws tp Col B from apivalues
FindOptions optsLookupB = new FindOptions();
optsLookupB.LookAtType = LookAtType.EntireContent;
optsLookupB.LookInType = LookInType.Values;
optsLookupB.SetRange(areaApivalues);
Cell iValue; Cell findRange; int countOccur = 0;
for (int i = 0; i < rngApiId.CellCount; i++)
{
iValue = rngApiId[i, 0];
findRange = wsApiValues.Cells.Find(iValue.Value, null, optsLookupB);
if (findRange != null)
{
countOccur++;
foreach (Cell cell in rngApiId)
{
...Here need some logic
}
//Debug.WriteLine(iValue.Name + "-" + findRange.Name);
}
}<a class="attachment" href="/uploads/default/45419">CompareColumnValuesAndCountOccurences.zip</a> (61.2 KB)
I’ve created a console app with just the functionality required. You’ll find in the project folder 2 .ODS files: APITemplate (which currently outputs the program) and APITemp_EXPECTED OUTPUT (which needs to be outputted). It will match Count column from API Report worksheet with column B from apivalues worksheet and will add the count of occurrences of each element in Count column. In Listing column is just adding corresponding values from column A (apivalues worksheet)
Thank you for the solution! It solved part of my requirement, however on the same sample of project if you look at the output spreadsheet file you’ll see that on column H are inserted the values from the matched index of apivalues spreadsheet column A. (it is documented on the file sent)
@Remus87,
I am afraid that there is no direct method to perform this task using Aspose.Cells library. You may please device your own logic to implement desired functionality.
Thanks. I’ve found a solution to that. Just need that the records to come each on a new line in the same cell. So according to: New Line in Cells|Documentation. I’ve followed the example:
{
orderList += wsApiValues.Cells[item.Row, 0].Value + “\n”;
}
cellsApiReport[cellApiID.Row, 7].PutValue(orderList);
}
// Wrap text on column H
var stWrapText = wbAPIReport.CreateStyle(); stWrapText.IsTextWrapped = true;
colH.ApplyStyle(stWrapText, new StyleFlag() { WrapText = true});
And is not doing the records on new line. Is word wrapping but not what I want (a record on each new line) Any advise ?
@Remus87,
I have tried this sample and it is working fine like in each row, multi-line text is displayed in individual cell with proper line break. Please give it a try and share the feedback.
Workbook workbook = new Workbook(); // Creating a Workbook object
Worksheet sheet = workbook.Worksheets[0];
sheet.Cells[2, 2].Value = "Use";
sheet.Cells[2, 2].Value += "\n with word wrap on to create a new line";
sheet.Cells[3, 2].Value = "Use";
sheet.Cells[3, 2].Value += "\n with word wrap on to create a new line";
sheet.Cells[4, 2].Value = "Use";
sheet.Cells[4, 2].Value += "\n with word wrap on to create a new line";
Style style = workbook.CreateStyle();
//Set Text Wrap property to true
style.IsTextWrapped = true;
//Set Cell's Style
sheet.Cells.Columns[2].ApplyStyle(style, new StyleFlag() { WrapText = true });
workbook.Save("test.xlsx");
It works fine for .Xlsx format, but for .ODS format (which I output) is not working.
I’ve tried with a simple text (“Hello\nWorld”), thought maybe is the data coming in, then using string interpolation, then using System.Environment NewLine object and still didn’t have a positive output with new line on .ODS
@Remus87,
We have observed the issue in output ODS file where wrap text does not take effect. This issue is logged in our database for further investigation. You will be notified here once any update is ready for sharing.
This issue is logged as: CELLSNET-47781 - Wrap Text not working for ODS files
This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.
Good to know that your issue is resolved by the new fix. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.
The issues you have found earlier (filed as CELLSNET-47781) have been fixed in this update. This message was posted using Bugs notification tool by simon.zhao