Table of Contents
...
Note |
---|
Columns that do not match up with one of the import names will be ignored and the first line on the import result will be a list of the ignored columns Useful Google Sheet calculations:
|
...
Code Block |
---|
foreach (var c in excel.Columns)
{
if (c != null)
{
string col = c.ToLower();
if (col.StartsWith("*"))
{
string profile = col.Substring(1);
int? profileId = ItemProfile.GetByName(Session, profile, ItemProfile.Usages.ItemForSale);
if (profileId.HasValue)
{
iProfiles.Add(i, profileId.Value);
}
else
{
Session.TextLog.add("Unknown custom profile " + col);
}
}
else if (col == "category") iCat = i;
else if (col.StartsWith("manufactur") || col == "supplier") iSupplier = i;
else if (col == "brand") iBrand = i;
else if (col == "range") iRange = i;
else if (col == "name") iName = i;
else if (col == "status") iStatus = i;
else if (col == "uom") iUOM = i;
else if (col.Contains("image") && col.Contains("url")) iImage = i;
else if (col.Contains("warranty") && col.Contains("month")) iWarrantyMonths = i;
else if (col.Contains("purchase") && col.Contains("multiple")) iPurchaseMultiple = i;
else if (col.Contains("unit") && (col.Contains("qty") || col.Contains("quantity"))) iQtyUnit = i;
else if (col.Contains("buy") && col.Contains("sell")) iBuySell = i;
else if (col == "sku") iSKU = i;
else if (col == "colour") iColour = i;
else if (col == "size") iSize = i;
else if (col.Contains("group") && (col.Contains("size") || col.Contains("colour"))) iGroup = i;
else if (col.Contains("storage")) iStorage = i;
else if ((col.Contains("style") && (col.Contains("group") || col.Length < 10)) || col == "productgroup") iStyleGroup = i;
else if (col == "description") iDesc = i;
else if (col.Contains("short") && col.Contains("description")) iShortDesc = i;
else if (col.Contains("web") && col.Contains("description")) iWebDescription = i;
else if ((col.Contains("web") || col.Contains("html")) && col.Contains("features")) iWebFeatures = i;
else if (col.Contains("purchasing") && col.Contains("notes")) iPurchasingNotes = i;
else if (col.Contains("sellprice")) iSellPrice = i;
else if (col == "costprice" || col == "defaultbuyprice") iCostPrice = i;
else if (col.Contains("cost") && col.StartsWith("av")) iavgCost = i;
else if (col.Contains("price") && col.StartsWith("alt") && col.Contains("buy")) iAltBuyPrice = i;
else if (col.Contains("rrp")) iRRP = i;
else if (col.Contains("gst")) iGSTMode = i;
else if ((col.Contains("their") || col.Contains("supplier")) && col.Contains("part") && col.Contains("number")) iSupplierRef = i;
else if (col.Contains("supplier") && col.Contains("name") && (col.Contains("item") || col.Contains("part"))) iSupplierPartName = i;
else if (col == "extref" || col == "ext ref" || col == "xref" || col.StartsWith("import")) iExtRef = i;
else if (col == "dimunit") iDimUnit = i;
else if (col == "width") iWidth = i;
else if (col == "height") iHeight = i;
else if (col.Contains("depth") && col.Contains("unit")) iUnitDepth = i;
else if (col.Contains("width") && col.Contains("unit")) iUnitWidth = i;
else if (col.Contains("height") && col.Contains("unit")) iUnitHeight = i;
else if (col == "depth") iDepth = i;
else if (col == "massunit") iMassUnit = i;
else if (col == "netmass") iNetMass = i;
else if (col == "grossmass") iGrossMass = i;
else if (col.Contains("measure"))
{
if (col.Contains("unit")) iMeasureUnit = i; else iMeasure = i;
}
else if (col.Contains("sell") && col.Contains("rate")) iSellrate = i;
else if (col == "barcode") iBarcode = i;
else if (col == "assembly") iAssembly = i;
else if (col.Contains("repair")) iRepairable = i;
else if (col.Contains("serving") && col.Contains("size")) iServingSize = i;
else if (col.Contains("name") && (col.Contains("pkg") || col.Contains("package"))) iPackageName = i;
else if (col.Contains("size") && col.Contains("pack")) iPacksize = i;
else if (col.Contains("packing") && col.Contains("factor")) iPackingFactor = i;
else if (col.Contains("serving") && col.Contains("per") && col.Contains("pack")) iServPerPack = i;
else if (col.StartsWith("ingredients")) iIngredients = i;
else if (col.StartsWith("certification") || col.StartsWith("lifestyle"))
{
certifications.Add(i, col.Replace("certification", string.Empty));
}
else if (col.StartsWith("claims"))
{
dietaryClaims.Add(i, col.Replace("claims", string.Empty));
}
else if (col.StartsWith("nip") && !col.Contains("serve"))
{
int p = col.IndexOf("(");
if (p > 0)
{
col = col.Substring(0, p - 1);
}
string text = col.Replace("nip", string.Empty).Replace(":", string.Empty).Trim();
int nipId = ArticleNIPItem.IdForText(Session, text);
if (nipId > 0) iNIP.Add(i, nipId); else Session.TextLog.add("No NIP item found for " + text);
}
else if (col.StartsWith("inner"))
{
if (col.Contains("qty") || col.Contains("quantity"))
{
iInnerQty = i;
}
else if (col.Contains("sell"))
{
iInnerSellPrice = i;
}
else
{
iInnerBuyPrice = i;
}
}
else if (col.StartsWith("carton"))
{
if (col.Contains("qty") || col.Contains("quantity"))
{
iCartonQty = i;
}
else if (col.Contains("sell"))
{
iCartonSellPrice = i;
}
else
{
iCartonBuyPrice = i;
}
}
else if (col.StartsWith("pallet"))
{
if (col.Contains("qty") || col.Contains("quantity"))
{
iPalletQty = i;
}
else
{
iPalletBuyPrice = i;
}
else if (col.Contains("depth") && col.Contains("carton")) iCartonDepth = i;
else if (col.Contains("width") && col.Contains("carton")) iCartonWidth = i;
else if (col.Contains("height") && col.Contains("carton")) iCartonHeight = i;
else if (col.Contains("barcode") && col.Contains("carton")) iCartonBarcode = i;
}
else
{
Session.TextLog.add("Column ignored: " + c);
}
}
i++;
} |
...