当前位置: 首页>>代码示例>>Golang>>正文


Golang Cell.String方法代码示例

本文整理汇总了Golang中github.com/tealeg/xlsx.Cell.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Cell.String方法的具体用法?Golang Cell.String怎么用?Golang Cell.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tealeg/xlsx.Cell的用法示例。


在下文中一共展示了Cell.String方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: xlsInsertValue

func xlsInsertValue(tree *XlsObjNode, keys []string, value *xlsx.Cell, offset int) {

	if tree.nodeType == ARRAY_TYPE {
		var valueList = tree.value.([]*XlsObjNode)
		var valueLen = len(valueList)
		var node *XlsObjNode

		// fmt.Println(keys[offset])
		// for _, child := range(tree.value.([]XlsObjNode)){
		// 	if findKey(tre)
		// }
		// needNew := findKey(tree, keys, offset)
		// dfs(tree)

		if valueLen == 0 {
			node = new(XlsObjNode)
			if keys[offset] == "id" {
				node.key = keys[offset]
			}
			node.nodeType = HASH_TYPE
			node.value = make([]*XlsObjNode, 0)
			tree.value = append(valueList, node)
		} else {
			node = valueList[valueLen-1]
		}

		needNew := xlsFindKey(node, keys, offset)

		if needNew {
			node = new(XlsObjNode)
			node.nodeType = HASH_TYPE
			node.value = make([]*XlsObjNode, 0)
			tree.value = append(valueList, node)
		}
		xlsInsertValue(node, keys, value, offset)
		return
	}

	if len(keys) == offset+1 {
		var child = new(XlsObjNode)

		if strings.HasSuffix(keys[offset], "*") {
			child.key = ""
			child.nodeType = VALUE_TYPE
			child.value = value.String()

			var valueList = tree.value.([]*XlsObjNode)
			for _, key := range valueList {
				key2 := keys[offset]
				if key2[:(len(key2)-1)] == key.key {
					// xlsInsertValue(key, keys, value, offset+1)
					key.value = append(key.value.([]*XlsObjNode), child)
					return
				}
			}

			var newXlsObjNode = new(XlsObjNode)
			tree.value = append(valueList, newXlsObjNode)
			newXlsObjNode.nodeType = ARRAY_TYPE
			newXlsObjNode.key = keys[offset][:len(keys[offset])-1]
			newXlsObjNode.value = make([]*XlsObjNode, 1)
			newXlsObjNode.value.([]*XlsObjNode)[0] = child
			return
		}
		child.key = keys[offset]

		if strings.HasSuffix(keys[offset], "$") { //属性类型
			child.nodeType = ATTR_TYPE
			child.key = child.key[:len(child.key)-1]
		} else {
			child.nodeType = VALUE_TYPE
		}
		child.value = value.String()
		tree.value = append(tree.value.([]*XlsObjNode), child)
		if child.key == "id" {
			tree.key = child.value.(string)
			tree.isId = true
		}

		return
	}

	var valueList = tree.value.([]*XlsObjNode)
	for _, key := range valueList {
		key2 := keys[offset]
		if key.key == keys[offset] || (strings.HasSuffix(key2, "*") && key2[:(len(key2)-1)] == key.key) {
			xlsInsertValue(key, keys, value, offset+1)
			return
		}
	}

	var newXlsObjNode = new(XlsObjNode)
	tree.value = append(valueList, newXlsObjNode)
	newXlsObjNode.key = keys[offset]
	newXlsObjNode.value = make([]*XlsObjNode, 0)

	if strings.HasSuffix(keys[offset], "*") { //数组类型
		newXlsObjNode.nodeType = ARRAY_TYPE
		newXlsObjNode.key = keys[offset][:len(keys[offset])-1]
	} else if strings.HasPrefix(keys[offset+1], "id") && len(keys) == 2 {
//.........这里部分代码省略.........
开发者ID:icetoggle,项目名称:allconvert,代码行数:101,代码来源:xls_parser.go


注:本文中的github.com/tealeg/xlsx.Cell.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。