i have made a TableDataSource which uses my custom TableCell with two Buttons in it.
List<ConductedActivitiesItem> _items = new List<ConductedActivitiesItem>();
foreach(var item in this._logicActivities.Steps)
{
_items.Add(new ConductedActivitiesItem(){ Date = "12-13", Text = item.Lines[0], Checked = null });
}
var ds = new ConductedActivitiesDataSource(_items);
var dg = new CSTableViewDelegate(null);
dg.SelectionChanged += this.Steps_SelectionChanged;
this.Pad_tbvMeasures.DataSource = null;
this.Pad_tbvMeasures.DataSource = ds;
this.Pad_tbvMeasures.Delegate = dg;
this.Pad_tbvMeasures.ReloadData();
the List has 4 Items:
a
b
c
d
The Table View Shows:
a
b
c
d
a
b
c
d
a
b
c
d
Does anyone of you have an idea why the List shows more Items than the DataSource has?
Check your NumberOfSections() and RowsInSetion() methods to verify that they are returning the correct values.
Related
Is it possible to create a Search in SuiteTalk using multiple criteria? I need to search for specific Location and items, using AND/OR logical operators. Something like location = 123 AND (item = 1 OR item = 2).
My code so far returns the result for a given location, but I need only 20-30ish items (not the 1400 i have in the warehouse. The location and the items change in every search, so I need to pass an array of items as filter/criteria.
My code so far
$searchValue = new RecordRef();
$searchValue->type = 'location';
$searchValue->internalId = 123;
$searchMultiSelectField = new SearchMultiSelectField();
setFields($searchMultiSelectField, array(
'operator' => 'anyOf',
'searchValue' => $searchValue
));
$locationSearchBasic->internalId = $searchMultiSelectField;
$itemSearch->inventoryLocationJoin = $locationSearchBasic;
$itemSearchAdvance->criteria = $itemSearch;
$request = new SearchRequest();
$request->searchRecord = $itemSearchAdvance;
$searchResponse = $service->search($request);
It is possible to have multiple criteria using AND, but as far as I know it is not possible to use OR criteria in a search. An example of the former would look something like this:
$searchValue = new RecordRef();
$searchValue->type = 'location';
$searchValue->internalId = 123;
$searchMultiSelectField = new SearchMultiSelectField();
setFields($searchMultiSelectField, array(
'operator' => 'anyOf',
'searchValue' => $searchValue
));
$locationSearchBasic->internalId = $searchMultiSelectField;
$itemSearch->inventoryLocationJoin = $locationSearchBasic;
// Add an item criteria
$searchStringField = new SearchStringField();
$searchStringField->searchValue = 1;
$itemSearchBasic = new ItemSearchBasic();
$itemSearchBasic->itemId = $searchStringField;
$itemSearch->basic = $itemSearchBasic;
$itemSearchAdvance->criteria = $itemSearch;
$request = new SearchRequest();
$request->searchRecord = $itemSearchAdvance;
$searchResponse = $service->search($request);
I have a Tableviewcontroller BeamsNameVC with 2 variables: Name and number.
If for example, the number is 7, and if I click on any row in this View controller, it will segue to another TableViewcontroller SpansListVC and than it will show 7 rows: S1, S2, S3, S4, S5, S6 & S7.
I want to save these Data, so I created 2 swift files:
class StructureElement: NSObject, NSCoding {
var name = ""
var nbrSpans = ""
var spans = [LoadDetailsForEachSpan]()
and
class LoadDetailsForEachSpan: NSObject, NSCoding {
var i_SpanName = ""
var i_Spanlength = ""
var i_ConcentratedLoadForEachSpans = [ConcentratedLoadForEachSpan]()
I created a protocol with the following:
let spanNbr = Int(structureElement[newRowIndex].nbrSpans)
let newElementDetailSpan = LoadDetailsForEachSpan()
for i in 0...spanNbr! {
newElementDetailSpan.i_SpanName = "S" + " \(i)"
structureElement[newRowIndex].spans.append(newElementDetailSpan)
}
If i run the application, it will segue to * SpansListVC* but all values are the last i.
Example:
if name is Test 7 and number of span is 7, I will be having inside *[Spans] * 7 values with the same name:
spans[0] = S 7
spans[1] = S 7
....
Any mistake with above code?
Welcome to the hell that mutable data objects can be ;). You are creating a single LoadDetailsForEachSpan instance and add that same instance a number of times to the array, while setting the i_SpanName property of that same instance every time the loop is iterated. You probably want to pull the instance creation into the loop:
for i in 0...spanNbr! {
let newElementDetailSpan = LoadDetailsForEachSpan()
newElementDetailSpan.i_SpanName = "S" + " \(i)"
structureElement[newRowIndex].spans.append(newElementDetailSpan)
}
Thanks #thm for your reply.
however, i find another solution as follow and it works:
var spanDetailAndLoadItem: [SpanDetailsAndLoads] = []
for var i in 1...nbr! {
let item = SpanDetailsAndLoads(name: "S\(i) - S\(i + 1)")
spanDetailAndLoadItem.append(item)
}
self.spans = spanDetailAndLoadItem
I create a column field in EPPlus like so:
// Column field[s]
var monthYrColField = pivotTable.Fields["MonthYr"];
pivotTable.ColumnFields.Add(monthYrColField);
...that displays like so (the "201509" and "201510" columns):
I want those values to display instead as "Sep 15" and "Oct 15"
In Excel Interop it's done like this:
var monthField = pvt.PivotFields("MonthYr");
monthField.Orientation = XlPivotFieldOrientation.xlColumnField;
monthField.NumberFormat = "MMM yy";
...but in EPPlus the corresponding variable (monthYrColField) has no "NumberFormat" (or "Style") member.
I tried this:
pivotTableWorksheet.Column(2).Style.Numberformat.Format = "MMM yy";
...but, while it didn't complain or wreak havoc, also did not change the vals from "201509" and "201510"
How can I change the format of my ColumnField column headings in EPPlus from "untransformed" to "MMM yy" format?
UPDATE
For VDWWD:
As you can see by the comments, there are many things related to PivotTables which don't work or are hard to get to work in EPPlus; Excel Interop is a bear (and not a teddy or a Koala, but more like a grizzly) compared to EPPlus, but as to PivotTables, it seems that EPPlus is kind of half-baked to compared to Exterop's fried-to-a-crispness.
private void PopulatePivotTableSheet()
{
string NORTHWEST_CORNER_OF_PIVOT_TABLE = "A6";
AddPrePivotTableDataToPivotTableSheet();
var dataRange = pivotDataWorksheet.Cells[pivotDataWorksheet.Dimension.Address];
dataRange.AutoFitColumns();
var pivotTable = pivotTableWorksheet.PivotTables.Add(
pivotTableWorksheet.Cells[NORTHWEST_CORNER_OF_PIVOT_TABLE],
dataRange,
"PivotTable");
pivotTable.MultipleFieldFilters = true;
pivotTable.GridDropZones = false;
pivotTable.Outline = false;
pivotTable.OutlineData = false;
pivotTable.ShowError = true;
pivotTable.ErrorCaption = "[error]";
pivotTable.ShowHeaders = true;
pivotTable.UseAutoFormatting = true;
pivotTable.ApplyWidthHeightFormats = true;
pivotTable.ShowDrill = true;
// Row field[s]
var descRowField = pivotTable.Fields["Description"];
pivotTable.RowFields.Add(descRowField);
// Column field[s]
var monthYrColField = pivotTable.Fields["MonthYr"];
pivotTable.ColumnFields.Add(monthYrColField);
// Data field[s]
var totQtyField = pivotTable.Fields["TotalQty"];
pivotTable.DataFields.Add(totQtyField);
var totPriceField = pivotTable.Fields["TotalPrice"];
pivotTable.DataFields.Add(totPriceField);
// Don't know how to calc these vals here, so had to put them on the data sheet
var avgPriceField = pivotTable.Fields["AvgPrice"];
pivotTable.DataFields.Add(avgPriceField);
var prcntgOfTotalField = pivotTable.Fields["PrcntgOfTotal"];
pivotTable.DataFields.Add(prcntgOfTotalField);
// TODO: Get the sorting (by sales, descending) working:
// These two lines don't seem that they would do so, but they do result in the items
// being sorted by (grand) total purchases descending
//var fld = ((PivotField)pvt.PivotFields("Description"));
//fld.AutoSort(2, "Total Purchases");
//int dataCnt = pivotTable.ra //DataBodyRange.Columns.Count + 1;
FormatPivotTable();
}
private void FormatPivotTable()
{
int HEADER_ROW = 7;
if (DateTimeFormatInfo.CurrentInfo != null)
pivotTableWorksheet.Column(2).Style.Numberformat.Format =
DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
// Pivot Table Header Row - bold and increase height
using (var headerRowFirstCell = pivotTableWorksheet.Cells[HEADER_ROW, 1])
{
headerRowFirstCell.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
headerRowFirstCell.Style.Font.Bold = true;
headerRowFirstCell.Style.Font.Size = 12;
pivotTableWorksheet.Row(HEADER_ROW).Height = 25;
}
ColorizeContractItemBlocks(contractItemDescs);
// TODO: Why is the hiding not working?
HideItemsWithFewerThan1PercentOfSales();
}
You can use the build-in Date format YearMonthPattern. which would give september 2016 as format.
pivotTableWorksheet.Column(2).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
If you really want MMM yy as pattern, you need to overwrite the culture format:
Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL")
{
DateTimeFormat = { YearMonthPattern = "MMM yy" }
};
pivotTableWorksheet.Column(2).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.YearMonthPattern;
It doesn't seem that you can set the format on the field itself. You have to access through the pivot table object:
pivotTable.DataFields[0].Format = "MMM yy";
Any formatting applied to the underlying worksheet seems to be completely ignored.
I am trying to get the filed names from 2 sharepoint lists and put them into 2 different dropdownlist on a webpart. However, there were some repeating field names in the dropdownlist. I wonder if my code is correct. or is there any other method to achieve the goal?
DataTable table = new DataTable("table");
DataColumn column;
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "Title";
table.Columns.Add(column);
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "Internal";
table.Columns.Add(column);
DataRow row;
foreach (SPField f in importList.Fields)
{
row = table.NewRow();
row["Title"] = f.Title;
row["Internal"] = f.InternalName;
table.Rows.Add(row);
}
ddlImport.DataSource = table;
ddlImport.DataTextField = "Title";
ddlImport.DataValueField = "Internal";
ddlImport.DataBind();
You may consider Removing hidden field
foreach (SPField f in importList.Fields)
{
if (!f.Hidden)
{
row = table.NewRow();
row["Title"] = f.Title;
row["Internal"] = f.InternalName;
table.Rows.Add(row);
}
}
I tried to read the existing excel file and copied to another path, and then i tried to insert data to the file i cloned. But I can' insert data. I don't know where I made mistake. But Here I've given my code.
Error occured in the line sheetData.InsertAt<Row>(row,++rowIndex);. Please help me out.
Package spreadsheetPackage = Package.Open(destinationFile, FileMode.Open, FileAccess.ReadWrite);
using (var document = SpreadsheetDocument.Open(spreadsheetPackage))
{
foreach (System.Data.DataTable table in ds.Tables)
{
var workbookPart = document.WorkbookPart;
var workbook = workbookPart.Workbook;
var sheet = workbookPart.Workbook.Descendants<Sheet>().FirstOrDefault();
Worksheet ws = ((WorksheetPart)(workbookPart.GetPartById(sheet.Id))).Worksheet;
SheetData sheetData = ws.GetFirstChild<SheetData>();
//Sheet sheet = sheets.FirstOrDefault();
if(sheet==null)
throw new Exception("No sheed found in the template file. Please add the sheet");
int rowIndex = 10, colIndex = 0;
bool flag = false;
var worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id);
var sharedStringPart = workbookPart.SharedStringTablePart;
var values = sharedStringPart.SharedStringTable.Elements<SharedStringItem>().ToArray();
var rows = worksheetPart.Worksheet.Descendants<Row>();
List<String> columns = new List<string>();
foreach (System.Data.DataColumn column in table.Columns)
{
columns.Add(column.ColumnName);
}
foreach (System.Data.DataRow dsrow in table.Rows)
{
Row row = new Row();
foreach (String col in columns)
{
DocumentFormat.OpenXml.Spreadsheet.Cell cell = new Cell();
cell.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
cell.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(dsrow[col].ToString());
row.AppendChild<Cell>(cell);
}
sheetData.InsertAt<Row>(row,++rowIndex);
}
}
Before you append Row, you should mentioned the row index to the instance...
row.RowIndex = (UInt32)rowIndex++;