id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
158,300 | 360EntSecGroup-Skylar/excelize | datavalidation.go | NewDataValidation | func NewDataValidation(allowBlank bool) *DataValidation {
return &DataValidation{
AllowBlank: allowBlank,
ShowErrorMessage: false,
ShowInputMessage: false,
}
} | go | func NewDataValidation(allowBlank bool) *DataValidation {
return &DataValidation{
AllowBlank: allowBlank,
ShowErrorMessage: false,
ShowInputMessage: false,
}
} | [
"func",
"NewDataValidation",
"(",
"allowBlank",
"bool",
")",
"*",
"DataValidation",
"{",
"return",
"&",
"DataValidation",
"{",
"AllowBlank",
":",
"allowBlank",
",",
"ShowErrorMessage",
":",
"false",
",",
"ShowInputMessage",
":",
"false",
",",
"}",
"\n",
"}"
] | // NewDataValidation return data validation struct. | [
"NewDataValidation",
"return",
"data",
"validation",
"struct",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L76-L82 |
158,301 | 360EntSecGroup-Skylar/excelize | datavalidation.go | SetError | func (dd *DataValidation) SetError(style DataValidationErrorStyle, title, msg string) {
dd.Error = &msg
dd.ErrorTitle = &title
strStyle := styleStop
switch style {
case DataValidationErrorStyleStop:
strStyle = styleStop
case DataValidationErrorStyleWarning:
strStyle = styleWarning
case DataValidationErrorStyleInformation:
strStyle = styleInformation
}
dd.ShowErrorMessage = true
dd.ErrorStyle = &strStyle
} | go | func (dd *DataValidation) SetError(style DataValidationErrorStyle, title, msg string) {
dd.Error = &msg
dd.ErrorTitle = &title
strStyle := styleStop
switch style {
case DataValidationErrorStyleStop:
strStyle = styleStop
case DataValidationErrorStyleWarning:
strStyle = styleWarning
case DataValidationErrorStyleInformation:
strStyle = styleInformation
}
dd.ShowErrorMessage = true
dd.ErrorStyle = &strStyle
} | [
"func",
"(",
"dd",
"*",
"DataValidation",
")",
"SetError",
"(",
"style",
"DataValidationErrorStyle",
",",
"title",
",",
"msg",
"string",
")",
"{",
"dd",
".",
"Error",
"=",
"&",
"msg",
"\n",
"dd",
".",
"ErrorTitle",
"=",
"&",
"title",
"\n",
"strStyle",
... | // SetError set error notice. | [
"SetError",
"set",
"error",
"notice",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L85-L100 |
158,302 | 360EntSecGroup-Skylar/excelize | datavalidation.go | SetInput | func (dd *DataValidation) SetInput(title, msg string) {
dd.ShowInputMessage = true
dd.PromptTitle = &title
dd.Prompt = &msg
} | go | func (dd *DataValidation) SetInput(title, msg string) {
dd.ShowInputMessage = true
dd.PromptTitle = &title
dd.Prompt = &msg
} | [
"func",
"(",
"dd",
"*",
"DataValidation",
")",
"SetInput",
"(",
"title",
",",
"msg",
"string",
")",
"{",
"dd",
".",
"ShowInputMessage",
"=",
"true",
"\n",
"dd",
".",
"PromptTitle",
"=",
"&",
"title",
"\n",
"dd",
".",
"Prompt",
"=",
"&",
"msg",
"\n",
... | // SetInput set prompt notice. | [
"SetInput",
"set",
"prompt",
"notice",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L103-L107 |
158,303 | 360EntSecGroup-Skylar/excelize | datavalidation.go | SetDropList | func (dd *DataValidation) SetDropList(keys []string) error {
formula := "\"" + strings.Join(keys, ",") + "\""
if dataValidationFormulaStrLen < len(formula) {
return fmt.Errorf(dataValidationFormulaStrLenErr)
}
dd.Formula1 = formula
dd.Type = convDataValidationType(typeList)
return nil
} | go | func (dd *DataValidation) SetDropList(keys []string) error {
formula := "\"" + strings.Join(keys, ",") + "\""
if dataValidationFormulaStrLen < len(formula) {
return fmt.Errorf(dataValidationFormulaStrLenErr)
}
dd.Formula1 = formula
dd.Type = convDataValidationType(typeList)
return nil
} | [
"func",
"(",
"dd",
"*",
"DataValidation",
")",
"SetDropList",
"(",
"keys",
"[",
"]",
"string",
")",
"error",
"{",
"formula",
":=",
"\"",
"\\\"",
"\"",
"+",
"strings",
".",
"Join",
"(",
"keys",
",",
"\"",
"\"",
")",
"+",
"\"",
"\\\"",
"\"",
"\n",
... | // SetDropList data validation list. | [
"SetDropList",
"data",
"validation",
"list",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L110-L118 |
158,304 | 360EntSecGroup-Skylar/excelize | datavalidation.go | SetRange | func (dd *DataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error {
formula1 := fmt.Sprintf("%d", f1)
formula2 := fmt.Sprintf("%d", f2)
if dataValidationFormulaStrLen < len(dd.Formula1) || dataValidationFormulaStrLen < len(dd.Formula2) {
return fmt.Errorf(dataValidationFormulaStrLenErr)
}
dd.Formula1 = formula1
dd.Formula2 = formula2
dd.Type = convDataValidationType(t)
dd.Operator = convDataValidationOperatior(o)
return nil
} | go | func (dd *DataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error {
formula1 := fmt.Sprintf("%d", f1)
formula2 := fmt.Sprintf("%d", f2)
if dataValidationFormulaStrLen < len(dd.Formula1) || dataValidationFormulaStrLen < len(dd.Formula2) {
return fmt.Errorf(dataValidationFormulaStrLenErr)
}
dd.Formula1 = formula1
dd.Formula2 = formula2
dd.Type = convDataValidationType(t)
dd.Operator = convDataValidationOperatior(o)
return nil
} | [
"func",
"(",
"dd",
"*",
"DataValidation",
")",
"SetRange",
"(",
"f1",
",",
"f2",
"int",
",",
"t",
"DataValidationType",
",",
"o",
"DataValidationOperator",
")",
"error",
"{",
"formula1",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f1",
")",
"\n... | // SetRange provides function to set data validation range in drop list. | [
"SetRange",
"provides",
"function",
"to",
"set",
"data",
"validation",
"range",
"in",
"drop",
"list",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L121-L133 |
158,305 | 360EntSecGroup-Skylar/excelize | datavalidation.go | SetSqref | func (dd *DataValidation) SetSqref(sqref string) {
if dd.Sqref == "" {
dd.Sqref = sqref
} else {
dd.Sqref = fmt.Sprintf("%s %s", dd.Sqref, sqref)
}
} | go | func (dd *DataValidation) SetSqref(sqref string) {
if dd.Sqref == "" {
dd.Sqref = sqref
} else {
dd.Sqref = fmt.Sprintf("%s %s", dd.Sqref, sqref)
}
} | [
"func",
"(",
"dd",
"*",
"DataValidation",
")",
"SetSqref",
"(",
"sqref",
"string",
")",
"{",
"if",
"dd",
".",
"Sqref",
"==",
"\"",
"\"",
"{",
"dd",
".",
"Sqref",
"=",
"sqref",
"\n",
"}",
"else",
"{",
"dd",
".",
"Sqref",
"=",
"fmt",
".",
"Sprintf"... | // SetSqref provides function to set data validation range in drop list. | [
"SetSqref",
"provides",
"function",
"to",
"set",
"data",
"validation",
"range",
"in",
"drop",
"list",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L157-L163 |
158,306 | 360EntSecGroup-Skylar/excelize | datavalidation.go | convDataValidationType | func convDataValidationType(t DataValidationType) string {
typeMap := map[DataValidationType]string{
typeNone: "none",
DataValidationTypeCustom: "custom",
DataValidationTypeDate: "date",
DataValidationTypeDecimal: "decimal",
typeList: "list",
DataValidationTypeTextLeng: "textLength",
DataValidationTypeTime: "time",
DataValidationTypeWhole: "whole",
}
return typeMap[t]
} | go | func convDataValidationType(t DataValidationType) string {
typeMap := map[DataValidationType]string{
typeNone: "none",
DataValidationTypeCustom: "custom",
DataValidationTypeDate: "date",
DataValidationTypeDecimal: "decimal",
typeList: "list",
DataValidationTypeTextLeng: "textLength",
DataValidationTypeTime: "time",
DataValidationTypeWhole: "whole",
}
return typeMap[t]
} | [
"func",
"convDataValidationType",
"(",
"t",
"DataValidationType",
")",
"string",
"{",
"typeMap",
":=",
"map",
"[",
"DataValidationType",
"]",
"string",
"{",
"typeNone",
":",
"\"",
"\"",
",",
"DataValidationTypeCustom",
":",
"\"",
"\"",
",",
"DataValidationTypeDate... | // convDataValidationType get excel data validation type. | [
"convDataValidationType",
"get",
"excel",
"data",
"validation",
"type",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L166-L180 |
158,307 | 360EntSecGroup-Skylar/excelize | datavalidation.go | convDataValidationOperatior | func convDataValidationOperatior(o DataValidationOperator) string {
typeMap := map[DataValidationOperator]string{
DataValidationOperatorBetween: "between",
DataValidationOperatorEqual: "equal",
DataValidationOperatorGreaterThan: "greaterThan",
DataValidationOperatorGreaterThanOrEqual: "greaterThanOrEqual",
DataValidationOperatorLessThan: "lessThan",
DataValidationOperatorLessThanOrEqual: "lessThanOrEqual",
DataValidationOperatorNotBetween: "notBetween",
DataValidationOperatorNotEqual: "notEqual",
}
return typeMap[o]
} | go | func convDataValidationOperatior(o DataValidationOperator) string {
typeMap := map[DataValidationOperator]string{
DataValidationOperatorBetween: "between",
DataValidationOperatorEqual: "equal",
DataValidationOperatorGreaterThan: "greaterThan",
DataValidationOperatorGreaterThanOrEqual: "greaterThanOrEqual",
DataValidationOperatorLessThan: "lessThan",
DataValidationOperatorLessThanOrEqual: "lessThanOrEqual",
DataValidationOperatorNotBetween: "notBetween",
DataValidationOperatorNotEqual: "notEqual",
}
return typeMap[o]
} | [
"func",
"convDataValidationOperatior",
"(",
"o",
"DataValidationOperator",
")",
"string",
"{",
"typeMap",
":=",
"map",
"[",
"DataValidationOperator",
"]",
"string",
"{",
"DataValidationOperatorBetween",
":",
"\"",
"\"",
",",
"DataValidationOperatorEqual",
":",
"\"",
"... | // convDataValidationOperatior get excel data validation operator. | [
"convDataValidationOperatior",
"get",
"excel",
"data",
"validation",
"operator",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/datavalidation.go#L183-L197 |
158,308 | 360EntSecGroup-Skylar/excelize | lib.go | ReadZipReader | func ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
fileList := make(map[string][]byte)
worksheets := 0
for _, v := range r.File {
fileList[v.Name] = readFile(v)
if len(v.Name) > 18 {
if v.Name[0:19] == "xl/worksheets/sheet" {
worksheets++
}
}
}
return fileList, worksheets, nil
} | go | func ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
fileList := make(map[string][]byte)
worksheets := 0
for _, v := range r.File {
fileList[v.Name] = readFile(v)
if len(v.Name) > 18 {
if v.Name[0:19] == "xl/worksheets/sheet" {
worksheets++
}
}
}
return fileList, worksheets, nil
} | [
"func",
"ReadZipReader",
"(",
"r",
"*",
"zip",
".",
"Reader",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
",",
"int",
",",
"error",
")",
"{",
"fileList",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"byte",
")",
"\n",
"wor... | // ReadZipReader can be used to read an XLSX in memory without touching the
// filesystem. | [
"ReadZipReader",
"can",
"be",
"used",
"to",
"read",
"an",
"XLSX",
"in",
"memory",
"without",
"touching",
"the",
"filesystem",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L24-L36 |
158,309 | 360EntSecGroup-Skylar/excelize | lib.go | readXML | func (f *File) readXML(name string) []byte {
if content, ok := f.XLSX[name]; ok {
return content
}
return []byte{}
} | go | func (f *File) readXML(name string) []byte {
if content, ok := f.XLSX[name]; ok {
return content
}
return []byte{}
} | [
"func",
"(",
"f",
"*",
"File",
")",
"readXML",
"(",
"name",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"content",
",",
"ok",
":=",
"f",
".",
"XLSX",
"[",
"name",
"]",
";",
"ok",
"{",
"return",
"content",
"\n",
"}",
"\n",
"return",
"[",
"]",
... | // readXML provides a function to read XML content as string. | [
"readXML",
"provides",
"a",
"function",
"to",
"read",
"XML",
"content",
"as",
"string",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L39-L44 |
158,310 | 360EntSecGroup-Skylar/excelize | lib.go | saveFileList | func (f *File) saveFileList(name string, content []byte) {
newContent := make([]byte, 0, len(XMLHeader)+len(content))
newContent = append(newContent, []byte(XMLHeader)...)
newContent = append(newContent, content...)
f.XLSX[name] = newContent
} | go | func (f *File) saveFileList(name string, content []byte) {
newContent := make([]byte, 0, len(XMLHeader)+len(content))
newContent = append(newContent, []byte(XMLHeader)...)
newContent = append(newContent, content...)
f.XLSX[name] = newContent
} | [
"func",
"(",
"f",
"*",
"File",
")",
"saveFileList",
"(",
"name",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"{",
"newContent",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"0",
",",
"len",
"(",
"XMLHeader",
")",
"+",
"len",
"(",
"content",
")"... | // saveFileList provides a function to update given file content in file list
// of XLSX. | [
"saveFileList",
"provides",
"a",
"function",
"to",
"update",
"given",
"file",
"content",
"in",
"file",
"list",
"of",
"XLSX",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L48-L53 |
158,311 | 360EntSecGroup-Skylar/excelize | lib.go | readFile | func readFile(file *zip.File) []byte {
rc, err := file.Open()
if err != nil {
log.Fatal(err)
}
buff := bytes.NewBuffer(nil)
_, _ = io.Copy(buff, rc)
rc.Close()
return buff.Bytes()
} | go | func readFile(file *zip.File) []byte {
rc, err := file.Open()
if err != nil {
log.Fatal(err)
}
buff := bytes.NewBuffer(nil)
_, _ = io.Copy(buff, rc)
rc.Close()
return buff.Bytes()
} | [
"func",
"readFile",
"(",
"file",
"*",
"zip",
".",
"File",
")",
"[",
"]",
"byte",
"{",
"rc",
",",
"err",
":=",
"file",
".",
"Open",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"err",
")",
"\n",
"}",
"\n",
"buff",
... | // Read file content as string in a archive file. | [
"Read",
"file",
"content",
"as",
"string",
"in",
"a",
"archive",
"file",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L56-L65 |
158,312 | 360EntSecGroup-Skylar/excelize | lib.go | JoinCellName | func JoinCellName(col string, row int) (string, error) {
normCol := strings.Map(func(rune rune) rune {
switch {
case 'A' <= rune && rune <= 'Z':
return rune
case 'a' <= rune && rune <= 'z':
return rune - 32
}
return -1
}, col)
if len(col) == 0 || len(col) != len(normCol) {
return "", newInvalidColumnNameError(col)
}
if row < 1 {
return "", newInvalidRowNumberError(row)
}
return fmt.Sprintf("%s%d", normCol, row), nil
} | go | func JoinCellName(col string, row int) (string, error) {
normCol := strings.Map(func(rune rune) rune {
switch {
case 'A' <= rune && rune <= 'Z':
return rune
case 'a' <= rune && rune <= 'z':
return rune - 32
}
return -1
}, col)
if len(col) == 0 || len(col) != len(normCol) {
return "", newInvalidColumnNameError(col)
}
if row < 1 {
return "", newInvalidRowNumberError(row)
}
return fmt.Sprintf("%s%d", normCol, row), nil
} | [
"func",
"JoinCellName",
"(",
"col",
"string",
",",
"row",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"normCol",
":=",
"strings",
".",
"Map",
"(",
"func",
"(",
"rune",
"rune",
")",
"rune",
"{",
"switch",
"{",
"case",
"'A'",
"<=",
"rune",
"&&... | // JoinCellName joins cell name from column name and row number. | [
"JoinCellName",
"joins",
"cell",
"name",
"from",
"column",
"name",
"and",
"row",
"number",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L91-L108 |
158,313 | 360EntSecGroup-Skylar/excelize | lib.go | namespaceStrictToTransitional | func namespaceStrictToTransitional(content []byte) []byte {
var namespaceTranslationDic = map[string]string{
StrictSourceRelationship: SourceRelationship,
StrictSourceRelationshipChart: SourceRelationshipChart,
StrictSourceRelationshipComments: SourceRelationshipComments,
StrictSourceRelationshipImage: SourceRelationshipImage,
StrictNameSpaceSpreadSheet: NameSpaceSpreadSheet,
}
for s, n := range namespaceTranslationDic {
content = bytes.Replace(content, []byte(s), []byte(n), -1)
}
return content
} | go | func namespaceStrictToTransitional(content []byte) []byte {
var namespaceTranslationDic = map[string]string{
StrictSourceRelationship: SourceRelationship,
StrictSourceRelationshipChart: SourceRelationshipChart,
StrictSourceRelationshipComments: SourceRelationshipComments,
StrictSourceRelationshipImage: SourceRelationshipImage,
StrictNameSpaceSpreadSheet: NameSpaceSpreadSheet,
}
for s, n := range namespaceTranslationDic {
content = bytes.Replace(content, []byte(s), []byte(n), -1)
}
return content
} | [
"func",
"namespaceStrictToTransitional",
"(",
"content",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"var",
"namespaceTranslationDic",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"StrictSourceRelationship",
":",
"SourceRelationship",
",",
"StrictSourceRelations... | // namespaceStrictToTransitional provides a method to convert Strict and
// Transitional namespaces. | [
"namespaceStrictToTransitional",
"provides",
"a",
"method",
"to",
"convert",
"Strict",
"and",
"Transitional",
"namespaces",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/lib.go#L221-L233 |
158,314 | 360EntSecGroup-Skylar/excelize | styles.go | formatToInt | func formatToInt(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return v
}
return fmt.Sprintf("%d", int(f))
} | go | func formatToInt(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return v
}
return fmt.Sprintf("%d", int(f))
} | [
"func",
"formatToInt",
"(",
"i",
"int",
",",
"v",
"string",
")",
"string",
"{",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"v",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
"\n",
"}",
"\n",
"return",
"fmt",
... | // formatToInt provides a function to convert original string to integer
// format as string type by given built-in number formats code and cell
// string. | [
"formatToInt",
"provides",
"a",
"function",
"to",
"convert",
"original",
"string",
"to",
"integer",
"format",
"as",
"string",
"type",
"by",
"given",
"built",
"-",
"in",
"number",
"formats",
"code",
"and",
"cell",
"string",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L850-L856 |
158,315 | 360EntSecGroup-Skylar/excelize | styles.go | formatToA | func formatToA(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return v
}
if f < 0 {
t := int(math.Abs(f))
return fmt.Sprintf("(%d)", t)
}
t := int(f)
return fmt.Sprintf("%d", t)
} | go | func formatToA(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
return v
}
if f < 0 {
t := int(math.Abs(f))
return fmt.Sprintf("(%d)", t)
}
t := int(f)
return fmt.Sprintf("%d", t)
} | [
"func",
"formatToA",
"(",
"i",
"int",
",",
"v",
"string",
")",
"string",
"{",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"v",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
"\n",
"}",
"\n",
"if",
"f",
"<",
... | // formatToA provides a function to convert original string to special format
// as string type by given built-in number formats code and cell string. | [
"formatToA",
"provides",
"a",
"function",
"to",
"convert",
"original",
"string",
"to",
"special",
"format",
"as",
"string",
"type",
"by",
"given",
"built",
"-",
"in",
"number",
"formats",
"code",
"and",
"cell",
"string",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L871-L882 |
158,316 | 360EntSecGroup-Skylar/excelize | styles.go | is12HourTime | func is12HourTime(format string) bool {
return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
} | go | func is12HourTime(format string) bool {
return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
} | [
"func",
"is12HourTime",
"(",
"format",
"string",
")",
"bool",
"{",
"return",
"strings",
".",
"Contains",
"(",
"format",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"Contains",
"(",
"format",
",",
"\"",
"\"",
")",
"||",
"strings",
".",
"Contains",
"(",
... | // is12HourTime checks whether an Excel time format string is a 12 hours form. | [
"is12HourTime",
"checks",
"whether",
"an",
"Excel",
"time",
"format",
"string",
"is",
"a",
"12",
"hours",
"form",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L993-L995 |
158,317 | 360EntSecGroup-Skylar/excelize | styles.go | parseFormatStyleSet | func parseFormatStyleSet(style string) (*formatStyle, error) {
format := formatStyle{
DecimalPlaces: 2,
}
err := json.Unmarshal([]byte(style), &format)
return &format, err
} | go | func parseFormatStyleSet(style string) (*formatStyle, error) {
format := formatStyle{
DecimalPlaces: 2,
}
err := json.Unmarshal([]byte(style), &format)
return &format, err
} | [
"func",
"parseFormatStyleSet",
"(",
"style",
"string",
")",
"(",
"*",
"formatStyle",
",",
"error",
")",
"{",
"format",
":=",
"formatStyle",
"{",
"DecimalPlaces",
":",
"2",
",",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(... | // parseFormatStyleSet provides a function to parse the format settings of the
// cells and conditional formats. | [
"parseFormatStyleSet",
"provides",
"a",
"function",
"to",
"parse",
"the",
"format",
"settings",
"of",
"the",
"cells",
"and",
"conditional",
"formats",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L1019-L1025 |
158,318 | 360EntSecGroup-Skylar/excelize | styles.go | setFont | func setFont(formatStyle *formatStyle) *font {
fontUnderlineType := map[string]string{"single": "single", "double": "double"}
if formatStyle.Font.Size < 1 {
formatStyle.Font.Size = 11
}
if formatStyle.Font.Color == "" {
formatStyle.Font.Color = "#000000"
}
f := font{
B: formatStyle.Font.Bold,
I: formatStyle.Font.Italic,
Sz: &attrValInt{Val: formatStyle.Font.Size},
Color: &xlsxColor{RGB: getPaletteColor(formatStyle.Font.Color)},
Name: &attrValString{Val: formatStyle.Font.Family},
Family: &attrValInt{Val: 2},
}
if f.Name.Val == "" {
f.Name.Val = "Calibri"
f.Scheme = &attrValString{Val: "minor"}
}
val, ok := fontUnderlineType[formatStyle.Font.Underline]
if ok {
f.U = &attrValString{Val: val}
}
return &f
} | go | func setFont(formatStyle *formatStyle) *font {
fontUnderlineType := map[string]string{"single": "single", "double": "double"}
if formatStyle.Font.Size < 1 {
formatStyle.Font.Size = 11
}
if formatStyle.Font.Color == "" {
formatStyle.Font.Color = "#000000"
}
f := font{
B: formatStyle.Font.Bold,
I: formatStyle.Font.Italic,
Sz: &attrValInt{Val: formatStyle.Font.Size},
Color: &xlsxColor{RGB: getPaletteColor(formatStyle.Font.Color)},
Name: &attrValString{Val: formatStyle.Font.Family},
Family: &attrValInt{Val: 2},
}
if f.Name.Val == "" {
f.Name.Val = "Calibri"
f.Scheme = &attrValString{Val: "minor"}
}
val, ok := fontUnderlineType[formatStyle.Font.Underline]
if ok {
f.U = &attrValString{Val: val}
}
return &f
} | [
"func",
"setFont",
"(",
"formatStyle",
"*",
"formatStyle",
")",
"*",
"font",
"{",
"fontUnderlineType",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"\"",
"\"",
",",
"\"",
"\"",
":",
"\"",
"\"",
"}",
"\n",
"if",
"formatStyle",
".",... | // setFont provides a function to add font style by given cell format
// settings. | [
"setFont",
"provides",
"a",
"function",
"to",
"add",
"font",
"style",
"by",
"given",
"cell",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L1953-L1978 |
158,319 | 360EntSecGroup-Skylar/excelize | styles.go | setNumFmt | func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
dp := "0."
numFmtID := 164 // Default custom number format code from 164.
if formatStyle.DecimalPlaces < 0 || formatStyle.DecimalPlaces > 30 {
formatStyle.DecimalPlaces = 2
}
for i := 0; i < formatStyle.DecimalPlaces; i++ {
dp += "0"
}
if formatStyle.CustomNumFmt != nil {
return setCustomNumFmt(style, formatStyle)
}
_, ok := builtInNumFmt[formatStyle.NumFmt]
if !ok {
fc, currency := currencyNumFmt[formatStyle.NumFmt]
if !currency {
return setLangNumFmt(style, formatStyle)
}
fc = strings.Replace(fc, "0.00", dp, -1)
if formatStyle.NegRed {
fc = fc + ";[Red]" + fc
}
if style.NumFmts != nil {
numFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
nf := xlsxNumFmt{
FormatCode: fc,
NumFmtID: numFmtID,
}
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf := xlsxNumFmt{
FormatCode: fc,
NumFmtID: numFmtID,
}
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return numFmtID
}
return formatStyle.NumFmt
} | go | func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
dp := "0."
numFmtID := 164 // Default custom number format code from 164.
if formatStyle.DecimalPlaces < 0 || formatStyle.DecimalPlaces > 30 {
formatStyle.DecimalPlaces = 2
}
for i := 0; i < formatStyle.DecimalPlaces; i++ {
dp += "0"
}
if formatStyle.CustomNumFmt != nil {
return setCustomNumFmt(style, formatStyle)
}
_, ok := builtInNumFmt[formatStyle.NumFmt]
if !ok {
fc, currency := currencyNumFmt[formatStyle.NumFmt]
if !currency {
return setLangNumFmt(style, formatStyle)
}
fc = strings.Replace(fc, "0.00", dp, -1)
if formatStyle.NegRed {
fc = fc + ";[Red]" + fc
}
if style.NumFmts != nil {
numFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
nf := xlsxNumFmt{
FormatCode: fc,
NumFmtID: numFmtID,
}
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf := xlsxNumFmt{
FormatCode: fc,
NumFmtID: numFmtID,
}
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return numFmtID
}
return formatStyle.NumFmt
} | [
"func",
"setNumFmt",
"(",
"style",
"*",
"xlsxStyleSheet",
",",
"formatStyle",
"*",
"formatStyle",
")",
"int",
"{",
"dp",
":=",
"\"",
"\"",
"\n",
"numFmtID",
":=",
"164",
"// Default custom number format code from 164.",
"\n",
"if",
"formatStyle",
".",
"DecimalPlac... | // setNumFmt provides a function to check if number format code in the range
// of built-in values. | [
"setNumFmt",
"provides",
"a",
"function",
"to",
"check",
"if",
"number",
"format",
"code",
"in",
"the",
"range",
"of",
"built",
"-",
"in",
"values",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L1982-L2026 |
158,320 | 360EntSecGroup-Skylar/excelize | styles.go | setCustomNumFmt | func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
nf := xlsxNumFmt{FormatCode: *formatStyle.CustomNumFmt}
if style.NumFmts != nil {
nf.NumFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf.NumFmtID = 164
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return nf.NumFmtID
} | go | func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
nf := xlsxNumFmt{FormatCode: *formatStyle.CustomNumFmt}
if style.NumFmts != nil {
nf.NumFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf.NumFmtID = 164
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return nf.NumFmtID
} | [
"func",
"setCustomNumFmt",
"(",
"style",
"*",
"xlsxStyleSheet",
",",
"formatStyle",
"*",
"formatStyle",
")",
"int",
"{",
"nf",
":=",
"xlsxNumFmt",
"{",
"FormatCode",
":",
"*",
"formatStyle",
".",
"CustomNumFmt",
"}",
"\n",
"if",
"style",
".",
"NumFmts",
"!="... | // setCustomNumFmt provides a function to set custom number format code. | [
"setCustomNumFmt",
"provides",
"a",
"function",
"to",
"set",
"custom",
"number",
"format",
"code",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2029-L2044 |
158,321 | 360EntSecGroup-Skylar/excelize | styles.go | setLangNumFmt | func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
numFmts, ok := langNumFmt[formatStyle.Lang]
if !ok {
return 0
}
var fc string
fc, ok = numFmts[formatStyle.NumFmt]
if !ok {
return 0
}
nf := xlsxNumFmt{FormatCode: fc}
if style.NumFmts != nil {
nf.NumFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf.NumFmtID = formatStyle.NumFmt
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return nf.NumFmtID
} | go | func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
numFmts, ok := langNumFmt[formatStyle.Lang]
if !ok {
return 0
}
var fc string
fc, ok = numFmts[formatStyle.NumFmt]
if !ok {
return 0
}
nf := xlsxNumFmt{FormatCode: fc}
if style.NumFmts != nil {
nf.NumFmtID = style.NumFmts.NumFmt[len(style.NumFmts.NumFmt)-1].NumFmtID + 1
style.NumFmts.NumFmt = append(style.NumFmts.NumFmt, &nf)
style.NumFmts.Count++
} else {
nf.NumFmtID = formatStyle.NumFmt
numFmts := xlsxNumFmts{
NumFmt: []*xlsxNumFmt{&nf},
Count: 1,
}
style.NumFmts = &numFmts
}
return nf.NumFmtID
} | [
"func",
"setLangNumFmt",
"(",
"style",
"*",
"xlsxStyleSheet",
",",
"formatStyle",
"*",
"formatStyle",
")",
"int",
"{",
"numFmts",
",",
"ok",
":=",
"langNumFmt",
"[",
"formatStyle",
".",
"Lang",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"0",
"\n",
"}",
... | // setLangNumFmt provides a function to set number format code with language. | [
"setLangNumFmt",
"provides",
"a",
"function",
"to",
"set",
"number",
"format",
"code",
"with",
"language",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2047-L2071 |
158,322 | 360EntSecGroup-Skylar/excelize | styles.go | setFills | func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
var patterns = []string{
"none",
"solid",
"mediumGray",
"darkGray",
"lightGray",
"darkHorizontal",
"darkVertical",
"darkDown",
"darkUp",
"darkGrid",
"darkTrellis",
"lightHorizontal",
"lightVertical",
"lightDown",
"lightUp",
"lightGrid",
"lightTrellis",
"gray125",
"gray0625",
}
var variants = []float64{
90,
0,
45,
135,
}
var fill xlsxFill
switch formatStyle.Fill.Type {
case "gradient":
if len(formatStyle.Fill.Color) != 2 {
break
}
var gradient xlsxGradientFill
switch formatStyle.Fill.Shading {
case 0, 1, 2, 3:
gradient.Degree = variants[formatStyle.Fill.Shading]
case 4:
gradient.Type = "path"
case 5:
gradient.Type = "path"
gradient.Bottom = 0.5
gradient.Left = 0.5
gradient.Right = 0.5
gradient.Top = 0.5
default:
break
}
var stops []*xlsxGradientFillStop
for index, color := range formatStyle.Fill.Color {
var stop xlsxGradientFillStop
stop.Position = float64(index)
stop.Color.RGB = getPaletteColor(color)
stops = append(stops, &stop)
}
gradient.Stop = stops
fill.GradientFill = &gradient
case "pattern":
if formatStyle.Fill.Pattern > 18 || formatStyle.Fill.Pattern < 0 {
break
}
if len(formatStyle.Fill.Color) < 1 {
break
}
var pattern xlsxPatternFill
pattern.PatternType = patterns[formatStyle.Fill.Pattern]
if fg {
pattern.FgColor.RGB = getPaletteColor(formatStyle.Fill.Color[0])
} else {
pattern.BgColor.RGB = getPaletteColor(formatStyle.Fill.Color[0])
}
fill.PatternFill = &pattern
default:
return nil
}
return &fill
} | go | func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
var patterns = []string{
"none",
"solid",
"mediumGray",
"darkGray",
"lightGray",
"darkHorizontal",
"darkVertical",
"darkDown",
"darkUp",
"darkGrid",
"darkTrellis",
"lightHorizontal",
"lightVertical",
"lightDown",
"lightUp",
"lightGrid",
"lightTrellis",
"gray125",
"gray0625",
}
var variants = []float64{
90,
0,
45,
135,
}
var fill xlsxFill
switch formatStyle.Fill.Type {
case "gradient":
if len(formatStyle.Fill.Color) != 2 {
break
}
var gradient xlsxGradientFill
switch formatStyle.Fill.Shading {
case 0, 1, 2, 3:
gradient.Degree = variants[formatStyle.Fill.Shading]
case 4:
gradient.Type = "path"
case 5:
gradient.Type = "path"
gradient.Bottom = 0.5
gradient.Left = 0.5
gradient.Right = 0.5
gradient.Top = 0.5
default:
break
}
var stops []*xlsxGradientFillStop
for index, color := range formatStyle.Fill.Color {
var stop xlsxGradientFillStop
stop.Position = float64(index)
stop.Color.RGB = getPaletteColor(color)
stops = append(stops, &stop)
}
gradient.Stop = stops
fill.GradientFill = &gradient
case "pattern":
if formatStyle.Fill.Pattern > 18 || formatStyle.Fill.Pattern < 0 {
break
}
if len(formatStyle.Fill.Color) < 1 {
break
}
var pattern xlsxPatternFill
pattern.PatternType = patterns[formatStyle.Fill.Pattern]
if fg {
pattern.FgColor.RGB = getPaletteColor(formatStyle.Fill.Color[0])
} else {
pattern.BgColor.RGB = getPaletteColor(formatStyle.Fill.Color[0])
}
fill.PatternFill = &pattern
default:
return nil
}
return &fill
} | [
"func",
"setFills",
"(",
"formatStyle",
"*",
"formatStyle",
",",
"fg",
"bool",
")",
"*",
"xlsxFill",
"{",
"var",
"patterns",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
... | // setFills provides a function to add fill elements in the styles.xml by
// given cell format settings. | [
"setFills",
"provides",
"a",
"function",
"to",
"add",
"fill",
"elements",
"in",
"the",
"styles",
".",
"xml",
"by",
"given",
"cell",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2075-L2154 |
158,323 | 360EntSecGroup-Skylar/excelize | styles.go | setAlignment | func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
var alignment xlsxAlignment
if formatStyle.Alignment != nil {
alignment.Horizontal = formatStyle.Alignment.Horizontal
alignment.Indent = formatStyle.Alignment.Indent
alignment.JustifyLastLine = formatStyle.Alignment.JustifyLastLine
alignment.ReadingOrder = formatStyle.Alignment.ReadingOrder
alignment.RelativeIndent = formatStyle.Alignment.RelativeIndent
alignment.ShrinkToFit = formatStyle.Alignment.ShrinkToFit
alignment.TextRotation = formatStyle.Alignment.TextRotation
alignment.Vertical = formatStyle.Alignment.Vertical
alignment.WrapText = formatStyle.Alignment.WrapText
}
return &alignment
} | go | func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
var alignment xlsxAlignment
if formatStyle.Alignment != nil {
alignment.Horizontal = formatStyle.Alignment.Horizontal
alignment.Indent = formatStyle.Alignment.Indent
alignment.JustifyLastLine = formatStyle.Alignment.JustifyLastLine
alignment.ReadingOrder = formatStyle.Alignment.ReadingOrder
alignment.RelativeIndent = formatStyle.Alignment.RelativeIndent
alignment.ShrinkToFit = formatStyle.Alignment.ShrinkToFit
alignment.TextRotation = formatStyle.Alignment.TextRotation
alignment.Vertical = formatStyle.Alignment.Vertical
alignment.WrapText = formatStyle.Alignment.WrapText
}
return &alignment
} | [
"func",
"setAlignment",
"(",
"formatStyle",
"*",
"formatStyle",
")",
"*",
"xlsxAlignment",
"{",
"var",
"alignment",
"xlsxAlignment",
"\n",
"if",
"formatStyle",
".",
"Alignment",
"!=",
"nil",
"{",
"alignment",
".",
"Horizontal",
"=",
"formatStyle",
".",
"Alignmen... | // setAlignment provides a function to formatting information pertaining to
// text alignment in cells. There are a variety of choices for how text is
// aligned both horizontally and vertically, as well as indentation settings,
// and so on. | [
"setAlignment",
"provides",
"a",
"function",
"to",
"formatting",
"information",
"pertaining",
"to",
"text",
"alignment",
"in",
"cells",
".",
"There",
"are",
"a",
"variety",
"of",
"choices",
"for",
"how",
"text",
"is",
"aligned",
"both",
"horizontally",
"and",
... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2160-L2174 |
158,324 | 360EntSecGroup-Skylar/excelize | styles.go | setProtection | func setProtection(formatStyle *formatStyle) *xlsxProtection {
var protection xlsxProtection
if formatStyle.Protection != nil {
protection.Hidden = formatStyle.Protection.Hidden
protection.Locked = formatStyle.Protection.Locked
}
return &protection
} | go | func setProtection(formatStyle *formatStyle) *xlsxProtection {
var protection xlsxProtection
if formatStyle.Protection != nil {
protection.Hidden = formatStyle.Protection.Hidden
protection.Locked = formatStyle.Protection.Locked
}
return &protection
} | [
"func",
"setProtection",
"(",
"formatStyle",
"*",
"formatStyle",
")",
"*",
"xlsxProtection",
"{",
"var",
"protection",
"xlsxProtection",
"\n",
"if",
"formatStyle",
".",
"Protection",
"!=",
"nil",
"{",
"protection",
".",
"Hidden",
"=",
"formatStyle",
".",
"Protec... | // setProtection provides a function to set protection properties associated
// with the cell. | [
"setProtection",
"provides",
"a",
"function",
"to",
"set",
"protection",
"properties",
"associated",
"with",
"the",
"cell",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2178-L2185 |
158,325 | 360EntSecGroup-Skylar/excelize | styles.go | setBorders | func setBorders(formatStyle *formatStyle) *xlsxBorder {
var styles = []string{
"none",
"thin",
"medium",
"dashed",
"dotted",
"thick",
"double",
"hair",
"mediumDashed",
"dashDot",
"mediumDashDot",
"dashDotDot",
"mediumDashDotDot",
"slantDashDot",
}
var border xlsxBorder
for _, v := range formatStyle.Border {
if 0 <= v.Style && v.Style < 14 {
var color xlsxColor
color.RGB = getPaletteColor(v.Color)
switch v.Type {
case "left":
border.Left.Style = styles[v.Style]
border.Left.Color = &color
case "right":
border.Right.Style = styles[v.Style]
border.Right.Color = &color
case "top":
border.Top.Style = styles[v.Style]
border.Top.Color = &color
case "bottom":
border.Bottom.Style = styles[v.Style]
border.Bottom.Color = &color
case "diagonalUp":
border.Diagonal.Style = styles[v.Style]
border.Diagonal.Color = &color
border.DiagonalUp = true
case "diagonalDown":
border.Diagonal.Style = styles[v.Style]
border.Diagonal.Color = &color
border.DiagonalDown = true
}
}
}
return &border
} | go | func setBorders(formatStyle *formatStyle) *xlsxBorder {
var styles = []string{
"none",
"thin",
"medium",
"dashed",
"dotted",
"thick",
"double",
"hair",
"mediumDashed",
"dashDot",
"mediumDashDot",
"dashDotDot",
"mediumDashDotDot",
"slantDashDot",
}
var border xlsxBorder
for _, v := range formatStyle.Border {
if 0 <= v.Style && v.Style < 14 {
var color xlsxColor
color.RGB = getPaletteColor(v.Color)
switch v.Type {
case "left":
border.Left.Style = styles[v.Style]
border.Left.Color = &color
case "right":
border.Right.Style = styles[v.Style]
border.Right.Color = &color
case "top":
border.Top.Style = styles[v.Style]
border.Top.Color = &color
case "bottom":
border.Bottom.Style = styles[v.Style]
border.Bottom.Color = &color
case "diagonalUp":
border.Diagonal.Style = styles[v.Style]
border.Diagonal.Color = &color
border.DiagonalUp = true
case "diagonalDown":
border.Diagonal.Style = styles[v.Style]
border.Diagonal.Color = &color
border.DiagonalDown = true
}
}
}
return &border
} | [
"func",
"setBorders",
"(",
"formatStyle",
"*",
"formatStyle",
")",
"*",
"xlsxBorder",
"{",
"var",
"styles",
"=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
... | // setBorders provides a function to add border elements in the styles.xml by
// given borders format settings. | [
"setBorders",
"provides",
"a",
"function",
"to",
"add",
"border",
"elements",
"in",
"the",
"styles",
".",
"xml",
"by",
"given",
"borders",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2189-L2237 |
158,326 | 360EntSecGroup-Skylar/excelize | styles.go | setCellXfs | func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, applyAlignment, applyProtection bool, alignment *xlsxAlignment, protection *xlsxProtection) int {
var xf xlsxXf
xf.FontID = fontID
if fontID != 0 {
xf.ApplyFont = true
}
xf.NumFmtID = numFmtID
if numFmtID != 0 {
xf.ApplyNumberFormat = true
}
xf.FillID = fillID
xf.BorderID = borderID
style.CellXfs.Count++
xf.Alignment = alignment
xf.ApplyAlignment = applyAlignment
if applyProtection {
xf.ApplyProtection = applyProtection
xf.Protection = protection
}
xfID := 0
xf.XfID = &xfID
style.CellXfs.Xf = append(style.CellXfs.Xf, xf)
return style.CellXfs.Count - 1
} | go | func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, applyAlignment, applyProtection bool, alignment *xlsxAlignment, protection *xlsxProtection) int {
var xf xlsxXf
xf.FontID = fontID
if fontID != 0 {
xf.ApplyFont = true
}
xf.NumFmtID = numFmtID
if numFmtID != 0 {
xf.ApplyNumberFormat = true
}
xf.FillID = fillID
xf.BorderID = borderID
style.CellXfs.Count++
xf.Alignment = alignment
xf.ApplyAlignment = applyAlignment
if applyProtection {
xf.ApplyProtection = applyProtection
xf.Protection = protection
}
xfID := 0
xf.XfID = &xfID
style.CellXfs.Xf = append(style.CellXfs.Xf, xf)
return style.CellXfs.Count - 1
} | [
"func",
"setCellXfs",
"(",
"style",
"*",
"xlsxStyleSheet",
",",
"fontID",
",",
"numFmtID",
",",
"fillID",
",",
"borderID",
"int",
",",
"applyAlignment",
",",
"applyProtection",
"bool",
",",
"alignment",
"*",
"xlsxAlignment",
",",
"protection",
"*",
"xlsxProtecti... | // setCellXfs provides a function to set describes all of the formatting for a
// cell. | [
"setCellXfs",
"provides",
"a",
"function",
"to",
"set",
"describes",
"all",
"of",
"the",
"formatting",
"for",
"a",
"cell",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2241-L2264 |
158,327 | 360EntSecGroup-Skylar/excelize | styles.go | GetCellStyle | func (f *File) GetCellStyle(sheet, axis string) (int, error) {
xlsx, err := f.workSheetReader(sheet)
if err != nil {
return 0, err
}
cellData, col, _, err := f.prepareCell(xlsx, sheet, axis)
if err != nil {
return 0, err
}
return f.prepareCellStyle(xlsx, col, cellData.S), err
} | go | func (f *File) GetCellStyle(sheet, axis string) (int, error) {
xlsx, err := f.workSheetReader(sheet)
if err != nil {
return 0, err
}
cellData, col, _, err := f.prepareCell(xlsx, sheet, axis)
if err != nil {
return 0, err
}
return f.prepareCellStyle(xlsx, col, cellData.S), err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"GetCellStyle",
"(",
"sheet",
",",
"axis",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"xlsx",
",",
"err",
":=",
"f",
".",
"workSheetReader",
"(",
"sheet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // GetCellStyle provides a function to get cell style index by given worksheet
// name and cell coordinates. | [
"GetCellStyle",
"provides",
"a",
"function",
"to",
"get",
"cell",
"style",
"index",
"by",
"given",
"worksheet",
"name",
"and",
"cell",
"coordinates",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2268-L2278 |
158,328 | 360EntSecGroup-Skylar/excelize | styles.go | drawCondFmtAboveAverage | func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
AboveAverage: &format.AboveAverage,
DxfID: &format.Format,
}
} | go | func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
AboveAverage: &format.AboveAverage,
DxfID: &format.Format,
}
} | [
"func",
"drawCondFmtAboveAverage",
"(",
"p",
"int",
",",
"ct",
"string",
",",
"format",
"*",
"formatConditional",
")",
"*",
"xlsxCfRule",
"{",
"return",
"&",
"xlsxCfRule",
"{",
"Priority",
":",
"p",
"+",
"1",
",",
"Type",
":",
"validType",
"[",
"format",
... | // drawCondFmtAboveAverage provides a function to create conditional
// formatting rule for above average and below average by given priority,
// criteria type and format settings. | [
"drawCondFmtAboveAverage",
"provides",
"a",
"function",
"to",
"create",
"conditional",
"formatting",
"rule",
"for",
"above",
"average",
"and",
"below",
"average",
"by",
"given",
"priority",
"criteria",
"type",
"and",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2688-L2695 |
158,329 | 360EntSecGroup-Skylar/excelize | styles.go | drawCondFmtDataBar | func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
DataBar: &xlsxDataBar{
Cfvo: []*xlsxCfvo{{Type: format.MinType}, {Type: format.MaxType}},
Color: []*xlsxColor{{RGB: getPaletteColor(format.BarColor)}},
},
}
} | go | func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
DataBar: &xlsxDataBar{
Cfvo: []*xlsxCfvo{{Type: format.MinType}, {Type: format.MaxType}},
Color: []*xlsxColor{{RGB: getPaletteColor(format.BarColor)}},
},
}
} | [
"func",
"drawCondFmtDataBar",
"(",
"p",
"int",
",",
"ct",
"string",
",",
"format",
"*",
"formatConditional",
")",
"*",
"xlsxCfRule",
"{",
"return",
"&",
"xlsxCfRule",
"{",
"Priority",
":",
"p",
"+",
"1",
",",
"Type",
":",
"validType",
"[",
"format",
".",... | // drawCondFmtDataBar provides a function to create conditional formatting
// rule for data bar by given priority, criteria type and format settings. | [
"drawCondFmtDataBar",
"provides",
"a",
"function",
"to",
"create",
"conditional",
"formatting",
"rule",
"for",
"data",
"bar",
"by",
"given",
"priority",
"criteria",
"type",
"and",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2748-L2757 |
158,330 | 360EntSecGroup-Skylar/excelize | styles.go | drawConfFmtExp | func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
Formula: []string{format.Criteria},
DxfID: &format.Format,
}
} | go | func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
Type: validType[format.Type],
Formula: []string{format.Criteria},
DxfID: &format.Format,
}
} | [
"func",
"drawConfFmtExp",
"(",
"p",
"int",
",",
"ct",
"string",
",",
"format",
"*",
"formatConditional",
")",
"*",
"xlsxCfRule",
"{",
"return",
"&",
"xlsxCfRule",
"{",
"Priority",
":",
"p",
"+",
"1",
",",
"Type",
":",
"validType",
"[",
"format",
".",
"... | // drawConfFmtExp provides a function to create conditional formatting rule
// for expression by given priority, criteria type and format settings. | [
"drawConfFmtExp",
"provides",
"a",
"function",
"to",
"create",
"conditional",
"formatting",
"rule",
"for",
"expression",
"by",
"given",
"priority",
"criteria",
"type",
"and",
"format",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2761-L2768 |
158,331 | 360EntSecGroup-Skylar/excelize | styles.go | ThemeColor | func ThemeColor(baseColor string, tint float64) string {
if tint == 0 {
return "FF" + baseColor
}
r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
h, s, l := RGBToHSL(uint8(r), uint8(g), uint8(b))
if tint < 0 {
l *= (1 + tint)
} else {
l = l*(1-tint) + (1 - (1 - tint))
}
br, bg, bb := HSLToRGB(h, s, l)
return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)
} | go | func ThemeColor(baseColor string, tint float64) string {
if tint == 0 {
return "FF" + baseColor
}
r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
h, s, l := RGBToHSL(uint8(r), uint8(g), uint8(b))
if tint < 0 {
l *= (1 + tint)
} else {
l = l*(1-tint) + (1 - (1 - tint))
}
br, bg, bb := HSLToRGB(h, s, l)
return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)
} | [
"func",
"ThemeColor",
"(",
"baseColor",
"string",
",",
"tint",
"float64",
")",
"string",
"{",
"if",
"tint",
"==",
"0",
"{",
"return",
"\"",
"\"",
"+",
"baseColor",
"\n",
"}",
"\n",
"r",
",",
"_",
":=",
"strconv",
".",
"ParseInt",
"(",
"baseColor",
"[... | // ThemeColor applied the color with tint value. | [
"ThemeColor",
"applied",
"the",
"color",
"with",
"tint",
"value",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/styles.go#L2785-L2800 |
158,332 | 360EntSecGroup-Skylar/excelize | shape.go | parseFormatShapeSet | func parseFormatShapeSet(formatSet string) (*formatShape, error) {
format := formatShape{
Width: 160,
Height: 160,
Format: formatPicture{
FPrintsWithSheet: true,
FLocksWithSheet: false,
NoChangeAspect: false,
OffsetX: 0,
OffsetY: 0,
XScale: 1.0,
YScale: 1.0,
},
}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | go | func parseFormatShapeSet(formatSet string) (*formatShape, error) {
format := formatShape{
Width: 160,
Height: 160,
Format: formatPicture{
FPrintsWithSheet: true,
FLocksWithSheet: false,
NoChangeAspect: false,
OffsetX: 0,
OffsetY: 0,
XScale: 1.0,
YScale: 1.0,
},
}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | [
"func",
"parseFormatShapeSet",
"(",
"formatSet",
"string",
")",
"(",
"*",
"formatShape",
",",
"error",
")",
"{",
"format",
":=",
"formatShape",
"{",
"Width",
":",
"160",
",",
"Height",
":",
"160",
",",
"Format",
":",
"formatPicture",
"{",
"FPrintsWithSheet",... | // parseFormatShapeSet provides a function to parse the format settings of the
// shape with default value. | [
"parseFormatShapeSet",
"provides",
"a",
"function",
"to",
"parse",
"the",
"format",
"settings",
"of",
"the",
"shape",
"with",
"default",
"value",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/shape.go#L20-L36 |
158,333 | 360EntSecGroup-Skylar/excelize | shape.go | setShapeRef | func setShapeRef(color string, i int) *aRef {
if color == "" {
return &aRef{
Idx: 0,
ScrgbClr: &aScrgbClr{
R: 0,
G: 0,
B: 0,
},
}
}
return &aRef{
Idx: i,
SrgbClr: &attrValString{
Val: strings.Replace(strings.ToUpper(color), "#", "", -1),
},
}
} | go | func setShapeRef(color string, i int) *aRef {
if color == "" {
return &aRef{
Idx: 0,
ScrgbClr: &aScrgbClr{
R: 0,
G: 0,
B: 0,
},
}
}
return &aRef{
Idx: i,
SrgbClr: &attrValString{
Val: strings.Replace(strings.ToUpper(color), "#", "", -1),
},
}
} | [
"func",
"setShapeRef",
"(",
"color",
"string",
",",
"i",
"int",
")",
"*",
"aRef",
"{",
"if",
"color",
"==",
"\"",
"\"",
"{",
"return",
"&",
"aRef",
"{",
"Idx",
":",
"0",
",",
"ScrgbClr",
":",
"&",
"aScrgbClr",
"{",
"R",
":",
"0",
",",
"G",
":",... | // setShapeRef provides a function to set color with hex model by given actual
// color value. | [
"setShapeRef",
"provides",
"a",
"function",
"to",
"set",
"color",
"with",
"hex",
"model",
"by",
"given",
"actual",
"color",
"value",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/shape.go#L438-L455 |
158,334 | 360EntSecGroup-Skylar/excelize | sheet.go | trimCell | func trimCell(column []xlsxC) []xlsxC {
col := make([]xlsxC, len(column))
i := 0
for _, c := range column {
if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
col[i] = c
i++
}
}
return col[0:i]
} | go | func trimCell(column []xlsxC) []xlsxC {
col := make([]xlsxC, len(column))
i := 0
for _, c := range column {
if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
col[i] = c
i++
}
}
return col[0:i]
} | [
"func",
"trimCell",
"(",
"column",
"[",
"]",
"xlsxC",
")",
"[",
"]",
"xlsxC",
"{",
"col",
":=",
"make",
"(",
"[",
"]",
"xlsxC",
",",
"len",
"(",
"column",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"column",
"{... | // trimCell provides a function to trim blank cells which created by completeCol. | [
"trimCell",
"provides",
"a",
"function",
"to",
"trim",
"blank",
"cells",
"which",
"created",
"by",
"completeCol",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L118-L128 |
158,335 | 360EntSecGroup-Skylar/excelize | sheet.go | setContentTypes | func (f *File) setContentTypes(index int) {
content := f.contentTypesReader()
content.Overrides = append(content.Overrides, xlsxOverride{
PartName: "/xl/worksheets/sheet" + strconv.Itoa(index) + ".xml",
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
})
} | go | func (f *File) setContentTypes(index int) {
content := f.contentTypesReader()
content.Overrides = append(content.Overrides, xlsxOverride{
PartName: "/xl/worksheets/sheet" + strconv.Itoa(index) + ".xml",
ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
})
} | [
"func",
"(",
"f",
"*",
"File",
")",
"setContentTypes",
"(",
"index",
"int",
")",
"{",
"content",
":=",
"f",
".",
"contentTypesReader",
"(",
")",
"\n",
"content",
".",
"Overrides",
"=",
"append",
"(",
"content",
".",
"Overrides",
",",
"xlsxOverride",
"{",... | // setContentTypes provides a function to read and update property of contents
// type of XLSX. | [
"setContentTypes",
"provides",
"a",
"function",
"to",
"read",
"and",
"update",
"property",
"of",
"contents",
"type",
"of",
"XLSX",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L132-L138 |
158,336 | 360EntSecGroup-Skylar/excelize | sheet.go | setSheet | func (f *File) setSheet(index int, name string) {
var xlsx xlsxWorksheet
xlsx.Dimension.Ref = "A1"
xlsx.SheetViews.SheetView = append(xlsx.SheetViews.SheetView, xlsxSheetView{
WorkbookViewID: 0,
})
path := "xl/worksheets/sheet" + strconv.Itoa(index) + ".xml"
f.sheetMap[trimSheetName(name)] = path
f.Sheet[path] = &xlsx
} | go | func (f *File) setSheet(index int, name string) {
var xlsx xlsxWorksheet
xlsx.Dimension.Ref = "A1"
xlsx.SheetViews.SheetView = append(xlsx.SheetViews.SheetView, xlsxSheetView{
WorkbookViewID: 0,
})
path := "xl/worksheets/sheet" + strconv.Itoa(index) + ".xml"
f.sheetMap[trimSheetName(name)] = path
f.Sheet[path] = &xlsx
} | [
"func",
"(",
"f",
"*",
"File",
")",
"setSheet",
"(",
"index",
"int",
",",
"name",
"string",
")",
"{",
"var",
"xlsx",
"xlsxWorksheet",
"\n",
"xlsx",
".",
"Dimension",
".",
"Ref",
"=",
"\"",
"\"",
"\n",
"xlsx",
".",
"SheetViews",
".",
"SheetView",
"=",... | // setSheet provides a function to update sheet property by given index. | [
"setSheet",
"provides",
"a",
"function",
"to",
"update",
"sheet",
"property",
"by",
"given",
"index",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L141-L150 |
158,337 | 360EntSecGroup-Skylar/excelize | sheet.go | setWorkbook | func (f *File) setWorkbook(name string, sheetID, rid int) {
content := f.workbookReader()
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
Name: trimSheetName(name),
SheetID: sheetID,
ID: "rId" + strconv.Itoa(rid),
})
} | go | func (f *File) setWorkbook(name string, sheetID, rid int) {
content := f.workbookReader()
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
Name: trimSheetName(name),
SheetID: sheetID,
ID: "rId" + strconv.Itoa(rid),
})
} | [
"func",
"(",
"f",
"*",
"File",
")",
"setWorkbook",
"(",
"name",
"string",
",",
"sheetID",
",",
"rid",
"int",
")",
"{",
"content",
":=",
"f",
".",
"workbookReader",
"(",
")",
"\n",
"content",
".",
"Sheets",
".",
"Sheet",
"=",
"append",
"(",
"content",... | // setWorkbook update workbook property of XLSX. Maximum 31 characters are
// allowed in sheet title. | [
"setWorkbook",
"update",
"workbook",
"property",
"of",
"XLSX",
".",
"Maximum",
"31",
"characters",
"are",
"allowed",
"in",
"sheet",
"title",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L154-L161 |
158,338 | 360EntSecGroup-Skylar/excelize | sheet.go | workbookRelsReader | func (f *File) workbookRelsReader() *xlsxWorkbookRels {
if f.WorkBookRels == nil {
var content xlsxWorkbookRels
_ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML("xl/_rels/workbook.xml.rels")), &content)
f.WorkBookRels = &content
}
return f.WorkBookRels
} | go | func (f *File) workbookRelsReader() *xlsxWorkbookRels {
if f.WorkBookRels == nil {
var content xlsxWorkbookRels
_ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML("xl/_rels/workbook.xml.rels")), &content)
f.WorkBookRels = &content
}
return f.WorkBookRels
} | [
"func",
"(",
"f",
"*",
"File",
")",
"workbookRelsReader",
"(",
")",
"*",
"xlsxWorkbookRels",
"{",
"if",
"f",
".",
"WorkBookRels",
"==",
"nil",
"{",
"var",
"content",
"xlsxWorkbookRels",
"\n",
"_",
"=",
"xml",
".",
"Unmarshal",
"(",
"namespaceStrictToTransiti... | // workbookRelsReader provides a function to read and unmarshal workbook
// relationships of XLSX file. | [
"workbookRelsReader",
"provides",
"a",
"function",
"to",
"read",
"and",
"unmarshal",
"workbook",
"relationships",
"of",
"XLSX",
"file",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L165-L172 |
158,339 | 360EntSecGroup-Skylar/excelize | sheet.go | addXlsxWorkbookRels | func (f *File) addXlsxWorkbookRels(sheet int) int {
content := f.workbookRelsReader()
rID := 0
for _, v := range content.Relationships {
t, _ := strconv.Atoi(strings.TrimPrefix(v.ID, "rId"))
if t > rID {
rID = t
}
}
rID++
ID := bytes.Buffer{}
ID.WriteString("rId")
ID.WriteString(strconv.Itoa(rID))
target := bytes.Buffer{}
target.WriteString("worksheets/sheet")
target.WriteString(strconv.Itoa(sheet))
target.WriteString(".xml")
content.Relationships = append(content.Relationships, xlsxWorkbookRelation{
ID: ID.String(),
Target: target.String(),
Type: SourceRelationshipWorkSheet,
})
return rID
} | go | func (f *File) addXlsxWorkbookRels(sheet int) int {
content := f.workbookRelsReader()
rID := 0
for _, v := range content.Relationships {
t, _ := strconv.Atoi(strings.TrimPrefix(v.ID, "rId"))
if t > rID {
rID = t
}
}
rID++
ID := bytes.Buffer{}
ID.WriteString("rId")
ID.WriteString(strconv.Itoa(rID))
target := bytes.Buffer{}
target.WriteString("worksheets/sheet")
target.WriteString(strconv.Itoa(sheet))
target.WriteString(".xml")
content.Relationships = append(content.Relationships, xlsxWorkbookRelation{
ID: ID.String(),
Target: target.String(),
Type: SourceRelationshipWorkSheet,
})
return rID
} | [
"func",
"(",
"f",
"*",
"File",
")",
"addXlsxWorkbookRels",
"(",
"sheet",
"int",
")",
"int",
"{",
"content",
":=",
"f",
".",
"workbookRelsReader",
"(",
")",
"\n",
"rID",
":=",
"0",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"content",
".",
"Relationsh... | // addXlsxWorkbookRels update workbook relationships property of XLSX. | [
"addXlsxWorkbookRels",
"update",
"workbook",
"relationships",
"property",
"of",
"XLSX",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L184-L207 |
158,340 | 360EntSecGroup-Skylar/excelize | sheet.go | replaceRelationshipsBytes | func replaceRelationshipsBytes(content []byte) []byte {
oldXmlns := []byte(`xmlns:relationships="http://schemas.openxmlformats.org/officeDocument/2006/relationships" relationships`)
newXmlns := []byte("r")
return bytes.Replace(content, oldXmlns, newXmlns, -1)
} | go | func replaceRelationshipsBytes(content []byte) []byte {
oldXmlns := []byte(`xmlns:relationships="http://schemas.openxmlformats.org/officeDocument/2006/relationships" relationships`)
newXmlns := []byte("r")
return bytes.Replace(content, oldXmlns, newXmlns, -1)
} | [
"func",
"replaceRelationshipsBytes",
"(",
"content",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"oldXmlns",
":=",
"[",
"]",
"byte",
"(",
"`xmlns:relationships=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" relationships`",
")",
"\n",
"newXmlns",
... | // replaceRelationshipsBytes; Some tools that read XLSX files have very strict
// requirements about the structure of the input XML. This function is a
// horrible hack to fix that after the XML marshalling is completed. | [
"replaceRelationshipsBytes",
";",
"Some",
"tools",
"that",
"read",
"XLSX",
"files",
"have",
"very",
"strict",
"requirements",
"about",
"the",
"structure",
"of",
"the",
"input",
"XML",
".",
"This",
"function",
"is",
"a",
"horrible",
"hack",
"to",
"fix",
"that",... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L217-L221 |
158,341 | 360EntSecGroup-Skylar/excelize | sheet.go | replaceRelationshipsNameSpaceBytes | func replaceRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
oldXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`)
newXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">`)
return bytes.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
} | go | func replaceRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
oldXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`)
newXmlns := []byte(`<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x15" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">`)
return bytes.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
} | [
"func",
"replaceRelationshipsNameSpaceBytes",
"(",
"workbookMarshal",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"oldXmlns",
":=",
"[",
"]",
"byte",
"(",
"`<workbook xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">`",
")",
"\n",
"newXmlns",
":=",
... | // replaceRelationshipsNameSpaceBytes; Some tools that read XLSX files have
// very strict requirements about the structure of the input XML. In
// particular both Numbers on the Mac and SAS dislike inline XML namespace
// declarations, or namespace prefixes that don't match the ones that Excel
// itself uses. This is a problem because the Go XML library doesn't multiple
// namespace declarations in a single element of a document. This function is
// a horrible hack to fix that after the XML marshalling is completed. | [
"replaceRelationshipsNameSpaceBytes",
";",
"Some",
"tools",
"that",
"read",
"XLSX",
"files",
"have",
"very",
"strict",
"requirements",
"about",
"the",
"structure",
"of",
"the",
"input",
"XML",
".",
"In",
"particular",
"both",
"Numbers",
"on",
"the",
"Mac",
"and"... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L230-L234 |
158,342 | 360EntSecGroup-Skylar/excelize | sheet.go | GetActiveSheetIndex | func (f *File) GetActiveSheetIndex() int {
for idx, name := range f.GetSheetMap() {
xlsx, _ := f.workSheetReader(name)
for _, sheetView := range xlsx.SheetViews.SheetView {
if sheetView.TabSelected {
return idx
}
}
}
return 0
} | go | func (f *File) GetActiveSheetIndex() int {
for idx, name := range f.GetSheetMap() {
xlsx, _ := f.workSheetReader(name)
for _, sheetView := range xlsx.SheetViews.SheetView {
if sheetView.TabSelected {
return idx
}
}
}
return 0
} | [
"func",
"(",
"f",
"*",
"File",
")",
"GetActiveSheetIndex",
"(",
")",
"int",
"{",
"for",
"idx",
",",
"name",
":=",
"range",
"f",
".",
"GetSheetMap",
"(",
")",
"{",
"xlsx",
",",
"_",
":=",
"f",
".",
"workSheetReader",
"(",
"name",
")",
"\n",
"for",
... | // GetActiveSheetIndex provides a function to get active sheet index of the
// XLSX. If not found the active sheet will be return integer 0. | [
"GetActiveSheetIndex",
"provides",
"a",
"function",
"to",
"get",
"active",
"sheet",
"index",
"of",
"the",
"XLSX",
".",
"If",
"not",
"found",
"the",
"active",
"sheet",
"will",
"be",
"return",
"integer",
"0",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L275-L285 |
158,343 | 360EntSecGroup-Skylar/excelize | sheet.go | SetSheetName | func (f *File) SetSheetName(oldName, newName string) {
oldName = trimSheetName(oldName)
newName = trimSheetName(newName)
content := f.workbookReader()
for k, v := range content.Sheets.Sheet {
if v.Name == oldName {
content.Sheets.Sheet[k].Name = newName
f.sheetMap[newName] = f.sheetMap[oldName]
delete(f.sheetMap, oldName)
}
}
} | go | func (f *File) SetSheetName(oldName, newName string) {
oldName = trimSheetName(oldName)
newName = trimSheetName(newName)
content := f.workbookReader()
for k, v := range content.Sheets.Sheet {
if v.Name == oldName {
content.Sheets.Sheet[k].Name = newName
f.sheetMap[newName] = f.sheetMap[oldName]
delete(f.sheetMap, oldName)
}
}
} | [
"func",
"(",
"f",
"*",
"File",
")",
"SetSheetName",
"(",
"oldName",
",",
"newName",
"string",
")",
"{",
"oldName",
"=",
"trimSheetName",
"(",
"oldName",
")",
"\n",
"newName",
"=",
"trimSheetName",
"(",
"newName",
")",
"\n",
"content",
":=",
"f",
".",
"... | // SetSheetName provides a function to set the worksheet name be given old and
// new worksheet name. Maximum 31 characters are allowed in sheet title and
// this function only changes the name of the sheet and will not update the
// sheet name in the formula or reference associated with the cell. So there
// may be problem formula error or reference missing. | [
"SetSheetName",
"provides",
"a",
"function",
"to",
"set",
"the",
"worksheet",
"name",
"be",
"given",
"old",
"and",
"new",
"worksheet",
"name",
".",
"Maximum",
"31",
"characters",
"are",
"allowed",
"in",
"sheet",
"title",
"and",
"this",
"function",
"only",
"c... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L292-L303 |
158,344 | 360EntSecGroup-Skylar/excelize | sheet.go | GetSheetName | func (f *File) GetSheetName(index int) string {
content := f.workbookReader()
rels := f.workbookRelsReader()
for _, rel := range rels.Relationships {
rID, _ := strconv.Atoi(strings.TrimSuffix(strings.TrimPrefix(rel.Target, "worksheets/sheet"), ".xml"))
if rID == index {
for _, v := range content.Sheets.Sheet {
if v.ID == rel.ID {
return v.Name
}
}
}
}
return ""
} | go | func (f *File) GetSheetName(index int) string {
content := f.workbookReader()
rels := f.workbookRelsReader()
for _, rel := range rels.Relationships {
rID, _ := strconv.Atoi(strings.TrimSuffix(strings.TrimPrefix(rel.Target, "worksheets/sheet"), ".xml"))
if rID == index {
for _, v := range content.Sheets.Sheet {
if v.ID == rel.ID {
return v.Name
}
}
}
}
return ""
} | [
"func",
"(",
"f",
"*",
"File",
")",
"GetSheetName",
"(",
"index",
"int",
")",
"string",
"{",
"content",
":=",
"f",
".",
"workbookReader",
"(",
")",
"\n",
"rels",
":=",
"f",
".",
"workbookRelsReader",
"(",
")",
"\n",
"for",
"_",
",",
"rel",
":=",
"r... | // GetSheetName provides a function to get worksheet name of XLSX by given
// worksheet index. If given sheet index is invalid, will return an empty
// string. | [
"GetSheetName",
"provides",
"a",
"function",
"to",
"get",
"worksheet",
"name",
"of",
"XLSX",
"by",
"given",
"worksheet",
"index",
".",
"If",
"given",
"sheet",
"index",
"is",
"invalid",
"will",
"return",
"an",
"empty",
"string",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L308-L322 |
158,345 | 360EntSecGroup-Skylar/excelize | sheet.go | getSheetMap | func (f *File) getSheetMap() map[string]string {
maps := make(map[string]string)
for idx, name := range f.GetSheetMap() {
maps[name] = "xl/worksheets/sheet" + strconv.Itoa(idx) + ".xml"
}
return maps
} | go | func (f *File) getSheetMap() map[string]string {
maps := make(map[string]string)
for idx, name := range f.GetSheetMap() {
maps[name] = "xl/worksheets/sheet" + strconv.Itoa(idx) + ".xml"
}
return maps
} | [
"func",
"(",
"f",
"*",
"File",
")",
"getSheetMap",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"maps",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"idx",
",",
"name",
":=",
"range",
"f",
".",
"GetSheetMap",
"... | // getSheetMap provides a function to get worksheet name and XML file path map of
// XLSX. | [
"getSheetMap",
"provides",
"a",
"function",
"to",
"get",
"worksheet",
"name",
"and",
"XML",
"file",
"path",
"map",
"of",
"XLSX",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L372-L378 |
158,346 | 360EntSecGroup-Skylar/excelize | sheet.go | SetSheetBackground | func (f *File) SetSheetBackground(sheet, picture string) error {
var err error
// Check picture exists first.
if _, err = os.Stat(picture); os.IsNotExist(err) {
return err
}
ext, ok := supportImageTypes[path.Ext(picture)]
if !ok {
return errors.New("unsupported image extension")
}
file, _ := ioutil.ReadFile(picture)
name := f.addMedia(file, ext)
rID := f.addSheetRelationships(sheet, SourceRelationshipImage, strings.Replace(name, "xl", "..", 1), "")
f.addSheetPicture(sheet, rID)
f.setContentTypePartImageExtensions()
return err
} | go | func (f *File) SetSheetBackground(sheet, picture string) error {
var err error
// Check picture exists first.
if _, err = os.Stat(picture); os.IsNotExist(err) {
return err
}
ext, ok := supportImageTypes[path.Ext(picture)]
if !ok {
return errors.New("unsupported image extension")
}
file, _ := ioutil.ReadFile(picture)
name := f.addMedia(file, ext)
rID := f.addSheetRelationships(sheet, SourceRelationshipImage, strings.Replace(name, "xl", "..", 1), "")
f.addSheetPicture(sheet, rID)
f.setContentTypePartImageExtensions()
return err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"SetSheetBackground",
"(",
"sheet",
",",
"picture",
"string",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"// Check picture exists first.",
"if",
"_",
",",
"err",
"=",
"os",
".",
"Stat",
"(",
"picture",
")",
";",
... | // SetSheetBackground provides a function to set background picture by given
// worksheet name and file path. | [
"SetSheetBackground",
"provides",
"a",
"function",
"to",
"set",
"background",
"picture",
"by",
"given",
"worksheet",
"name",
"and",
"file",
"path",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L382-L398 |
158,347 | 360EntSecGroup-Skylar/excelize | sheet.go | DeleteSheet | func (f *File) DeleteSheet(name string) {
content := f.workbookReader()
for k, v := range content.Sheets.Sheet {
if v.Name == trimSheetName(name) && len(content.Sheets.Sheet) > 1 {
content.Sheets.Sheet = append(content.Sheets.Sheet[:k], content.Sheets.Sheet[k+1:]...)
sheet := "xl/worksheets/sheet" + strconv.Itoa(v.SheetID) + ".xml"
rels := "xl/worksheets/_rels/sheet" + strconv.Itoa(v.SheetID) + ".xml.rels"
target := f.deleteSheetFromWorkbookRels(v.ID)
f.deleteSheetFromContentTypes(target)
f.deleteCalcChain(v.SheetID, "") // Delete CalcChain
delete(f.sheetMap, name)
delete(f.XLSX, sheet)
delete(f.XLSX, rels)
delete(f.Sheet, sheet)
f.SheetCount--
}
}
f.SetActiveSheet(len(f.GetSheetMap()))
} | go | func (f *File) DeleteSheet(name string) {
content := f.workbookReader()
for k, v := range content.Sheets.Sheet {
if v.Name == trimSheetName(name) && len(content.Sheets.Sheet) > 1 {
content.Sheets.Sheet = append(content.Sheets.Sheet[:k], content.Sheets.Sheet[k+1:]...)
sheet := "xl/worksheets/sheet" + strconv.Itoa(v.SheetID) + ".xml"
rels := "xl/worksheets/_rels/sheet" + strconv.Itoa(v.SheetID) + ".xml.rels"
target := f.deleteSheetFromWorkbookRels(v.ID)
f.deleteSheetFromContentTypes(target)
f.deleteCalcChain(v.SheetID, "") // Delete CalcChain
delete(f.sheetMap, name)
delete(f.XLSX, sheet)
delete(f.XLSX, rels)
delete(f.Sheet, sheet)
f.SheetCount--
}
}
f.SetActiveSheet(len(f.GetSheetMap()))
} | [
"func",
"(",
"f",
"*",
"File",
")",
"DeleteSheet",
"(",
"name",
"string",
")",
"{",
"content",
":=",
"f",
".",
"workbookReader",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"content",
".",
"Sheets",
".",
"Sheet",
"{",
"if",
"v",
".",
"Na... | // DeleteSheet provides a function to delete worksheet in a workbook by given
// worksheet name. Use this method with caution, which will affect changes in
// references such as formulas, charts, and so on. If there is any referenced
// value of the deleted worksheet, it will cause a file error when you open it.
// This function will be invalid when only the one worksheet is left. | [
"DeleteSheet",
"provides",
"a",
"function",
"to",
"delete",
"worksheet",
"in",
"a",
"workbook",
"by",
"given",
"worksheet",
"name",
".",
"Use",
"this",
"method",
"with",
"caution",
"which",
"will",
"affect",
"changes",
"in",
"references",
"such",
"as",
"formul... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L405-L423 |
158,348 | 360EntSecGroup-Skylar/excelize | sheet.go | copySheet | func (f *File) copySheet(from, to int) error {
sheet, err := f.workSheetReader("sheet" + strconv.Itoa(from))
if err != nil {
return err
}
worksheet := deepcopy.Copy(sheet).(*xlsxWorksheet)
path := "xl/worksheets/sheet" + strconv.Itoa(to) + ".xml"
if len(worksheet.SheetViews.SheetView) > 0 {
worksheet.SheetViews.SheetView[0].TabSelected = false
}
worksheet.Drawing = nil
worksheet.TableParts = nil
worksheet.PageSetUp = nil
f.Sheet[path] = worksheet
toRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(to) + ".xml.rels"
fromRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(from) + ".xml.rels"
_, ok := f.XLSX[fromRels]
if ok {
f.XLSX[toRels] = f.XLSX[fromRels]
}
return err
} | go | func (f *File) copySheet(from, to int) error {
sheet, err := f.workSheetReader("sheet" + strconv.Itoa(from))
if err != nil {
return err
}
worksheet := deepcopy.Copy(sheet).(*xlsxWorksheet)
path := "xl/worksheets/sheet" + strconv.Itoa(to) + ".xml"
if len(worksheet.SheetViews.SheetView) > 0 {
worksheet.SheetViews.SheetView[0].TabSelected = false
}
worksheet.Drawing = nil
worksheet.TableParts = nil
worksheet.PageSetUp = nil
f.Sheet[path] = worksheet
toRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(to) + ".xml.rels"
fromRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(from) + ".xml.rels"
_, ok := f.XLSX[fromRels]
if ok {
f.XLSX[toRels] = f.XLSX[fromRels]
}
return err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"copySheet",
"(",
"from",
",",
"to",
"int",
")",
"error",
"{",
"sheet",
",",
"err",
":=",
"f",
".",
"workSheetReader",
"(",
"\"",
"\"",
"+",
"strconv",
".",
"Itoa",
"(",
"from",
")",
")",
"\n",
"if",
"err",
"... | // copySheet provides a function to duplicate a worksheet by gave source and
// target worksheet name. | [
"copySheet",
"provides",
"a",
"function",
"to",
"duplicate",
"a",
"worksheet",
"by",
"gave",
"source",
"and",
"target",
"worksheet",
"name",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L468-L489 |
158,349 | 360EntSecGroup-Skylar/excelize | sheet.go | parseFormatPanesSet | func parseFormatPanesSet(formatSet string) (*formatPanes, error) {
format := formatPanes{}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | go | func parseFormatPanesSet(formatSet string) (*formatPanes, error) {
format := formatPanes{}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | [
"func",
"parseFormatPanesSet",
"(",
"formatSet",
"string",
")",
"(",
"*",
"formatPanes",
",",
"error",
")",
"{",
"format",
":=",
"formatPanes",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"formatSet",
")",
",",
"&... | // parseFormatPanesSet provides a function to parse the panes settings. | [
"parseFormatPanesSet",
"provides",
"a",
"function",
"to",
"parse",
"the",
"panes",
"settings",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L538-L542 |
158,350 | 360EntSecGroup-Skylar/excelize | sheet.go | UnprotectSheet | func (f *File) UnprotectSheet(sheet string) error {
xlsx, err := f.workSheetReader(sheet)
if err != nil {
return err
}
xlsx.SheetProtection = nil
return err
} | go | func (f *File) UnprotectSheet(sheet string) error {
xlsx, err := f.workSheetReader(sheet)
if err != nil {
return err
}
xlsx.SheetProtection = nil
return err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"UnprotectSheet",
"(",
"sheet",
"string",
")",
"error",
"{",
"xlsx",
",",
"err",
":=",
"f",
".",
"workSheetReader",
"(",
"sheet",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"xlsx"... | // UnprotectSheet provides a function to unprotect an Excel worksheet. | [
"UnprotectSheet",
"provides",
"a",
"function",
"to",
"unprotect",
"an",
"Excel",
"worksheet",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L810-L817 |
158,351 | 360EntSecGroup-Skylar/excelize | sheet.go | trimSheetName | func trimSheetName(name string) string {
if strings.ContainsAny(name, ":\\/?*[]") || utf8.RuneCountInString(name) > 31 {
r := make([]rune, 0, 31)
for _, v := range name {
switch v {
case 58, 92, 47, 63, 42, 91, 93: // replace :\/?*[]
continue
default:
r = append(r, v)
}
if len(r) == 31 {
break
}
}
name = string(r)
}
return name
} | go | func trimSheetName(name string) string {
if strings.ContainsAny(name, ":\\/?*[]") || utf8.RuneCountInString(name) > 31 {
r := make([]rune, 0, 31)
for _, v := range name {
switch v {
case 58, 92, 47, 63, 42, 91, 93: // replace :\/?*[]
continue
default:
r = append(r, v)
}
if len(r) == 31 {
break
}
}
name = string(r)
}
return name
} | [
"func",
"trimSheetName",
"(",
"name",
"string",
")",
"string",
"{",
"if",
"strings",
".",
"ContainsAny",
"(",
"name",
",",
"\"",
"\\\\",
"\"",
")",
"||",
"utf8",
".",
"RuneCountInString",
"(",
"name",
")",
">",
"31",
"{",
"r",
":=",
"make",
"(",
"[",... | // trimSheetName provides a function to trim invaild characters by given worksheet
// name. | [
"trimSheetName",
"provides",
"a",
"function",
"to",
"trim",
"invaild",
"characters",
"by",
"given",
"worksheet",
"name",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L821-L838 |
158,352 | 360EntSecGroup-Skylar/excelize | sheet.go | getPageLayout | func (o *PageLayoutOrientation) getPageLayout(ps *xlsxPageSetUp) {
// Excel default: portrait
if ps == nil || ps.Orientation == "" {
*o = OrientationPortrait
return
}
*o = PageLayoutOrientation(ps.Orientation)
} | go | func (o *PageLayoutOrientation) getPageLayout(ps *xlsxPageSetUp) {
// Excel default: portrait
if ps == nil || ps.Orientation == "" {
*o = OrientationPortrait
return
}
*o = PageLayoutOrientation(ps.Orientation)
} | [
"func",
"(",
"o",
"*",
"PageLayoutOrientation",
")",
"getPageLayout",
"(",
"ps",
"*",
"xlsxPageSetUp",
")",
"{",
"// Excel default: portrait",
"if",
"ps",
"==",
"nil",
"||",
"ps",
".",
"Orientation",
"==",
"\"",
"\"",
"{",
"*",
"o",
"=",
"OrientationPortrait... | // getPageLayout provides a method to get the orientation for the worksheet. | [
"getPageLayout",
"provides",
"a",
"method",
"to",
"get",
"the",
"orientation",
"for",
"the",
"worksheet",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L873-L880 |
158,353 | 360EntSecGroup-Skylar/excelize | sheet.go | getPageLayout | func (p *PageLayoutPaperSize) getPageLayout(ps *xlsxPageSetUp) {
// Excel default: 1
if ps == nil || ps.PaperSize == 0 {
*p = 1
return
}
*p = PageLayoutPaperSize(ps.PaperSize)
} | go | func (p *PageLayoutPaperSize) getPageLayout(ps *xlsxPageSetUp) {
// Excel default: 1
if ps == nil || ps.PaperSize == 0 {
*p = 1
return
}
*p = PageLayoutPaperSize(ps.PaperSize)
} | [
"func",
"(",
"p",
"*",
"PageLayoutPaperSize",
")",
"getPageLayout",
"(",
"ps",
"*",
"xlsxPageSetUp",
")",
"{",
"// Excel default: 1",
"if",
"ps",
"==",
"nil",
"||",
"ps",
".",
"PaperSize",
"==",
"0",
"{",
"*",
"p",
"=",
"1",
"\n",
"return",
"\n",
"}",
... | // getPageLayout provides a method to get the paper size for the worksheet. | [
"getPageLayout",
"provides",
"a",
"method",
"to",
"get",
"the",
"paper",
"size",
"for",
"the",
"worksheet",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L888-L895 |
158,354 | 360EntSecGroup-Skylar/excelize | sheet.go | prepareSheetXML | func prepareSheetXML(xlsx *xlsxWorksheet, col int, row int) {
rowCount := len(xlsx.SheetData.Row)
if rowCount < row {
// append missing rows
for rowIdx := rowCount; rowIdx < row; rowIdx++ {
xlsx.SheetData.Row = append(xlsx.SheetData.Row, xlsxRow{R: rowIdx + 1})
}
}
rowData := &xlsx.SheetData.Row[row-1]
fillColumns(rowData, col, row)
} | go | func prepareSheetXML(xlsx *xlsxWorksheet, col int, row int) {
rowCount := len(xlsx.SheetData.Row)
if rowCount < row {
// append missing rows
for rowIdx := rowCount; rowIdx < row; rowIdx++ {
xlsx.SheetData.Row = append(xlsx.SheetData.Row, xlsxRow{R: rowIdx + 1})
}
}
rowData := &xlsx.SheetData.Row[row-1]
fillColumns(rowData, col, row)
} | [
"func",
"prepareSheetXML",
"(",
"xlsx",
"*",
"xlsxWorksheet",
",",
"col",
"int",
",",
"row",
"int",
")",
"{",
"rowCount",
":=",
"len",
"(",
"xlsx",
".",
"SheetData",
".",
"Row",
")",
"\n",
"if",
"rowCount",
"<",
"row",
"{",
"// append missing rows",
"for... | // fillSheetData ensures there are enough rows, and columns in the chosen
// row to accept data. Missing rows are backfilled and given their row number | [
"fillSheetData",
"ensures",
"there",
"are",
"enough",
"rows",
"and",
"columns",
"in",
"the",
"chosen",
"row",
"to",
"accept",
"data",
".",
"Missing",
"rows",
"are",
"backfilled",
"and",
"given",
"their",
"row",
"number"
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/sheet.go#L1086-L1096 |
158,355 | 360EntSecGroup-Skylar/excelize | date.go | timeToExcelTime | func timeToExcelTime(t time.Time) (float64, error) {
// TODO in future this should probably also handle date1904 and like TimeFromExcelTime
// Force user to explicit convet passed value to UTC time.
// Because for example 1900-01-01 00:00:00 +0300 MSK converts to 1900-01-01 00:00:00 +0230 LMT
// probably due to daylight saving.
if t.Location() != time.UTC {
return 0.0, errors.New("only UTC time expected")
}
if t.Before(excelMinTime1900) {
return 0.0, nil
}
tt := t
diff := t.Sub(excelMinTime1900)
result := float64(0)
for diff >= maxDuration {
result += float64(maxDuration / dayNanoseconds)
tt = tt.Add(-maxDuration)
diff = tt.Sub(excelMinTime1900)
}
rem := diff % dayNanoseconds
result += float64(diff-rem)/float64(dayNanoseconds) + float64(rem)/float64(dayNanoseconds)
// Excel dates after 28th February 1900 are actually one day out.
// Excel behaves as though the date 29th February 1900 existed, which it didn't.
// Microsoft intentionally included this bug in Excel so that it would remain compatible with the spreadsheet
// program that had the majority market share at the time; Lotus 1-2-3.
// https://www.myonlinetraininghub.com/excel-date-and-time
if t.After(excelBuggyPeriodStart) {
result += 1.0
}
return result, nil
} | go | func timeToExcelTime(t time.Time) (float64, error) {
// TODO in future this should probably also handle date1904 and like TimeFromExcelTime
// Force user to explicit convet passed value to UTC time.
// Because for example 1900-01-01 00:00:00 +0300 MSK converts to 1900-01-01 00:00:00 +0230 LMT
// probably due to daylight saving.
if t.Location() != time.UTC {
return 0.0, errors.New("only UTC time expected")
}
if t.Before(excelMinTime1900) {
return 0.0, nil
}
tt := t
diff := t.Sub(excelMinTime1900)
result := float64(0)
for diff >= maxDuration {
result += float64(maxDuration / dayNanoseconds)
tt = tt.Add(-maxDuration)
diff = tt.Sub(excelMinTime1900)
}
rem := diff % dayNanoseconds
result += float64(diff-rem)/float64(dayNanoseconds) + float64(rem)/float64(dayNanoseconds)
// Excel dates after 28th February 1900 are actually one day out.
// Excel behaves as though the date 29th February 1900 existed, which it didn't.
// Microsoft intentionally included this bug in Excel so that it would remain compatible with the spreadsheet
// program that had the majority market share at the time; Lotus 1-2-3.
// https://www.myonlinetraininghub.com/excel-date-and-time
if t.After(excelBuggyPeriodStart) {
result += 1.0
}
return result, nil
} | [
"func",
"timeToExcelTime",
"(",
"t",
"time",
".",
"Time",
")",
"(",
"float64",
",",
"error",
")",
"{",
"// TODO in future this should probably also handle date1904 and like TimeFromExcelTime",
"// Force user to explicit convet passed value to UTC time.",
"// Because for example 1900-... | // timeToExcelTime provides a function to convert time to Excel time. | [
"timeToExcelTime",
"provides",
"a",
"function",
"to",
"convert",
"time",
"to",
"Excel",
"time",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/date.go#L29-L65 |
158,356 | 360EntSecGroup-Skylar/excelize | date.go | shiftJulianToNoon | func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
switch {
case -0.5 < julianFraction && julianFraction < 0.5:
julianFraction += 0.5
case julianFraction >= 0.5:
julianDays++
julianFraction -= 0.5
case julianFraction <= -0.5:
julianDays--
julianFraction += 1.5
}
return julianDays, julianFraction
} | go | func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
switch {
case -0.5 < julianFraction && julianFraction < 0.5:
julianFraction += 0.5
case julianFraction >= 0.5:
julianDays++
julianFraction -= 0.5
case julianFraction <= -0.5:
julianDays--
julianFraction += 1.5
}
return julianDays, julianFraction
} | [
"func",
"shiftJulianToNoon",
"(",
"julianDays",
",",
"julianFraction",
"float64",
")",
"(",
"float64",
",",
"float64",
")",
"{",
"switch",
"{",
"case",
"-",
"0.5",
"<",
"julianFraction",
"&&",
"julianFraction",
"<",
"0.5",
":",
"julianFraction",
"+=",
"0.5",
... | // shiftJulianToNoon provides a function to process julian date to noon. | [
"shiftJulianToNoon",
"provides",
"a",
"function",
"to",
"process",
"julian",
"date",
"to",
"noon",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/date.go#L68-L80 |
158,357 | 360EntSecGroup-Skylar/excelize | date.go | fractionOfADay | func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
const (
c1us = 1e3
c1s = 1e9
c1day = 24 * 60 * 60 * c1s
)
frac := int64(c1day*fraction + c1us/2)
nanoseconds = int((frac%c1s)/c1us) * c1us
frac /= c1s
seconds = int(frac % 60)
frac /= 60
minutes = int(frac % 60)
hours = int(frac / 60)
return
} | go | func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
const (
c1us = 1e3
c1s = 1e9
c1day = 24 * 60 * 60 * c1s
)
frac := int64(c1day*fraction + c1us/2)
nanoseconds = int((frac%c1s)/c1us) * c1us
frac /= c1s
seconds = int(frac % 60)
frac /= 60
minutes = int(frac % 60)
hours = int(frac / 60)
return
} | [
"func",
"fractionOfADay",
"(",
"fraction",
"float64",
")",
"(",
"hours",
",",
"minutes",
",",
"seconds",
",",
"nanoseconds",
"int",
")",
"{",
"const",
"(",
"c1us",
"=",
"1e3",
"\n",
"c1s",
"=",
"1e9",
"\n",
"c1day",
"=",
"24",
"*",
"60",
"*",
"60",
... | // fractionOfADay provides a function to return the integer values for hour,
// minutes, seconds and nanoseconds that comprised a given fraction of a day.
// values would round to 1 us. | [
"fractionOfADay",
"provides",
"a",
"function",
"to",
"return",
"the",
"integer",
"values",
"for",
"hour",
"minutes",
"seconds",
"and",
"nanoseconds",
"that",
"comprised",
"a",
"given",
"fraction",
"of",
"a",
"day",
".",
"values",
"would",
"round",
"to",
"1",
... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/date.go#L85-L101 |
158,358 | 360EntSecGroup-Skylar/excelize | rows.go | Next | func (rows *Rows) Next() bool {
for {
rows.token, rows.err = rows.decoder.Token()
if rows.err == io.EOF {
rows.err = nil
}
if rows.token == nil {
return false
}
switch startElement := rows.token.(type) {
case xml.StartElement:
inElement := startElement.Name.Local
if inElement == "row" {
return true
}
}
}
} | go | func (rows *Rows) Next() bool {
for {
rows.token, rows.err = rows.decoder.Token()
if rows.err == io.EOF {
rows.err = nil
}
if rows.token == nil {
return false
}
switch startElement := rows.token.(type) {
case xml.StartElement:
inElement := startElement.Name.Local
if inElement == "row" {
return true
}
}
}
} | [
"func",
"(",
"rows",
"*",
"Rows",
")",
"Next",
"(",
")",
"bool",
"{",
"for",
"{",
"rows",
".",
"token",
",",
"rows",
".",
"err",
"=",
"rows",
".",
"decoder",
".",
"Token",
"(",
")",
"\n",
"if",
"rows",
".",
"err",
"==",
"io",
".",
"EOF",
"{",... | // Next will return true if find the next row element. | [
"Next",
"will",
"return",
"true",
"if",
"find",
"the",
"next",
"row",
"element",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/rows.go#L104-L122 |
158,359 | 360EntSecGroup-Skylar/excelize | rows.go | Columns | func (rows *Rows) Columns() ([]string, error) {
if rows.token == nil {
return []string{}, nil
}
startElement := rows.token.(xml.StartElement)
r := xlsxRow{}
_ = rows.decoder.DecodeElement(&r, &startElement)
d := rows.f.sharedStringsReader()
columns := make([]string, len(r.C))
for _, colCell := range r.C {
col, _, err := CellNameToCoordinates(colCell.R)
if err != nil {
return columns, err
}
val, _ := colCell.getValueFrom(rows.f, d)
columns[col-1] = val
}
return columns, nil
} | go | func (rows *Rows) Columns() ([]string, error) {
if rows.token == nil {
return []string{}, nil
}
startElement := rows.token.(xml.StartElement)
r := xlsxRow{}
_ = rows.decoder.DecodeElement(&r, &startElement)
d := rows.f.sharedStringsReader()
columns := make([]string, len(r.C))
for _, colCell := range r.C {
col, _, err := CellNameToCoordinates(colCell.R)
if err != nil {
return columns, err
}
val, _ := colCell.getValueFrom(rows.f, d)
columns[col-1] = val
}
return columns, nil
} | [
"func",
"(",
"rows",
"*",
"Rows",
")",
"Columns",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"if",
"rows",
".",
"token",
"==",
"nil",
"{",
"return",
"[",
"]",
"string",
"{",
"}",
",",
"nil",
"\n",
"}",
"\n",
"startElement",
":="... | // Columns return the current row's column values | [
"Columns",
"return",
"the",
"current",
"row",
"s",
"column",
"values"
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/rows.go#L130-L148 |
158,360 | 360EntSecGroup-Skylar/excelize | rows.go | getTotalRowsCols | func (f *File) getTotalRowsCols(name string) (int, int, error) {
decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
var inElement string
var r xlsxRow
var tr, tc int
for {
token, _ := decoder.Token()
if token == nil {
break
}
switch startElement := token.(type) {
case xml.StartElement:
inElement = startElement.Name.Local
if inElement == "row" {
r = xlsxRow{}
_ = decoder.DecodeElement(&r, &startElement)
tr = r.R
for _, colCell := range r.C {
col, _, err := CellNameToCoordinates(colCell.R)
if err != nil {
return tr, tc, err
}
if col > tc {
tc = col
}
}
}
default:
}
}
return tr, tc, nil
} | go | func (f *File) getTotalRowsCols(name string) (int, int, error) {
decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
var inElement string
var r xlsxRow
var tr, tc int
for {
token, _ := decoder.Token()
if token == nil {
break
}
switch startElement := token.(type) {
case xml.StartElement:
inElement = startElement.Name.Local
if inElement == "row" {
r = xlsxRow{}
_ = decoder.DecodeElement(&r, &startElement)
tr = r.R
for _, colCell := range r.C {
col, _, err := CellNameToCoordinates(colCell.R)
if err != nil {
return tr, tc, err
}
if col > tc {
tc = col
}
}
}
default:
}
}
return tr, tc, nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"getTotalRowsCols",
"(",
"name",
"string",
")",
"(",
"int",
",",
"int",
",",
"error",
")",
"{",
"decoder",
":=",
"xml",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewReader",
"(",
"f",
".",
"readXML",
"(",
"name",
")... | // getTotalRowsCols provides a function to get total columns and rows in a
// worksheet. | [
"getTotalRowsCols",
"provides",
"a",
"function",
"to",
"get",
"total",
"columns",
"and",
"rows",
"in",
"a",
"worksheet",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/rows.go#L191-L222 |
158,361 | 360EntSecGroup-Skylar/excelize | rows.go | getRowHeight | func (f *File) getRowHeight(sheet string, row int) int {
xlsx, _ := f.workSheetReader(sheet)
for _, v := range xlsx.SheetData.Row {
if v.R == row+1 && v.Ht != 0 {
return int(convertRowHeightToPixels(v.Ht))
}
}
// Optimisation for when the row heights haven't changed.
return int(defaultRowHeightPixels)
} | go | func (f *File) getRowHeight(sheet string, row int) int {
xlsx, _ := f.workSheetReader(sheet)
for _, v := range xlsx.SheetData.Row {
if v.R == row+1 && v.Ht != 0 {
return int(convertRowHeightToPixels(v.Ht))
}
}
// Optimisation for when the row heights haven't changed.
return int(defaultRowHeightPixels)
} | [
"func",
"(",
"f",
"*",
"File",
")",
"getRowHeight",
"(",
"sheet",
"string",
",",
"row",
"int",
")",
"int",
"{",
"xlsx",
",",
"_",
":=",
"f",
".",
"workSheetReader",
"(",
"sheet",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"xlsx",
".",
"Sheet... | // getRowHeight provides a function to get row height in pixels by given sheet
// name and row index. | [
"getRowHeight",
"provides",
"a",
"function",
"to",
"get",
"row",
"height",
"in",
"pixels",
"by",
"given",
"sheet",
"name",
"and",
"row",
"index",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/rows.go#L249-L258 |
158,362 | 360EntSecGroup-Skylar/excelize | rows.go | convertRowHeightToPixels | func convertRowHeightToPixels(height float64) float64 {
var pixels float64
if height == 0 {
return pixels
}
pixels = math.Ceil(4.0 / 3.0 * height)
return pixels
} | go | func convertRowHeightToPixels(height float64) float64 {
var pixels float64
if height == 0 {
return pixels
}
pixels = math.Ceil(4.0 / 3.0 * height)
return pixels
} | [
"func",
"convertRowHeightToPixels",
"(",
"height",
"float64",
")",
"float64",
"{",
"var",
"pixels",
"float64",
"\n",
"if",
"height",
"==",
"0",
"{",
"return",
"pixels",
"\n",
"}",
"\n",
"pixels",
"=",
"math",
".",
"Ceil",
"(",
"4.0",
"/",
"3.0",
"*",
"... | // convertRowHeightToPixels provides a function to convert the height of a
// cell from user's units to pixels. If the height hasn't been set by the user
// we use the default value. If the row is hidden it has a value of zero. | [
"convertRowHeightToPixels",
"provides",
"a",
"function",
"to",
"convert",
"the",
"height",
"of",
"a",
"cell",
"from",
"user",
"s",
"units",
"to",
"pixels",
".",
"If",
"the",
"height",
"hasn",
"t",
"been",
"set",
"by",
"the",
"user",
"we",
"use",
"the",
"... | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/rows.go#L592-L599 |
158,363 | 360EntSecGroup-Skylar/excelize | chart.go | parseFormatChartSet | func parseFormatChartSet(formatSet string) (*formatChart, error) {
format := formatChart{
Dimension: formatChartDimension{
Width: 480,
Height: 290,
},
Format: formatPicture{
FPrintsWithSheet: true,
FLocksWithSheet: false,
NoChangeAspect: false,
OffsetX: 0,
OffsetY: 0,
XScale: 1.0,
YScale: 1.0,
},
Legend: formatChartLegend{
Position: "bottom",
ShowLegendKey: false,
},
Title: formatChartTitle{
Name: " ",
},
ShowBlanksAs: "gap",
}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | go | func parseFormatChartSet(formatSet string) (*formatChart, error) {
format := formatChart{
Dimension: formatChartDimension{
Width: 480,
Height: 290,
},
Format: formatPicture{
FPrintsWithSheet: true,
FLocksWithSheet: false,
NoChangeAspect: false,
OffsetX: 0,
OffsetY: 0,
XScale: 1.0,
YScale: 1.0,
},
Legend: formatChartLegend{
Position: "bottom",
ShowLegendKey: false,
},
Title: formatChartTitle{
Name: " ",
},
ShowBlanksAs: "gap",
}
err := json.Unmarshal([]byte(formatSet), &format)
return &format, err
} | [
"func",
"parseFormatChartSet",
"(",
"formatSet",
"string",
")",
"(",
"*",
"formatChart",
",",
"error",
")",
"{",
"format",
":=",
"formatChart",
"{",
"Dimension",
":",
"formatChartDimension",
"{",
"Width",
":",
"480",
",",
"Height",
":",
"290",
",",
"}",
",... | // parseFormatChartSet provides a function to parse the format settings of the
// chart with default value. | [
"parseFormatChartSet",
"provides",
"a",
"function",
"to",
"parse",
"the",
"format",
"settings",
"of",
"the",
"chart",
"with",
"default",
"value",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/chart.go#L273-L299 |
158,364 | 360EntSecGroup-Skylar/excelize | chart.go | prepareDrawing | func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) {
sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml"
if xlsx.Drawing != nil {
// The worksheet already has a picture or chart relationships, use the relationships drawing ../drawings/drawing%d.xml.
sheetRelationshipsDrawingXML = f.getSheetRelationshipsTargetByID(sheet, xlsx.Drawing.RID)
drawingID, _ = strconv.Atoi(strings.TrimSuffix(strings.TrimPrefix(sheetRelationshipsDrawingXML, "../drawings/drawing"), ".xml"))
drawingXML = strings.Replace(sheetRelationshipsDrawingXML, "..", "xl", -1)
} else {
// Add first picture for given sheet.
rID := f.addSheetRelationships(sheet, SourceRelationshipDrawingML, sheetRelationshipsDrawingXML, "")
f.addSheetDrawing(sheet, rID)
}
return drawingID, drawingXML
} | go | func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) {
sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml"
if xlsx.Drawing != nil {
// The worksheet already has a picture or chart relationships, use the relationships drawing ../drawings/drawing%d.xml.
sheetRelationshipsDrawingXML = f.getSheetRelationshipsTargetByID(sheet, xlsx.Drawing.RID)
drawingID, _ = strconv.Atoi(strings.TrimSuffix(strings.TrimPrefix(sheetRelationshipsDrawingXML, "../drawings/drawing"), ".xml"))
drawingXML = strings.Replace(sheetRelationshipsDrawingXML, "..", "xl", -1)
} else {
// Add first picture for given sheet.
rID := f.addSheetRelationships(sheet, SourceRelationshipDrawingML, sheetRelationshipsDrawingXML, "")
f.addSheetDrawing(sheet, rID)
}
return drawingID, drawingXML
} | [
"func",
"(",
"f",
"*",
"File",
")",
"prepareDrawing",
"(",
"xlsx",
"*",
"xlsxWorksheet",
",",
"drawingID",
"int",
",",
"sheet",
",",
"drawingXML",
"string",
")",
"(",
"int",
",",
"string",
")",
"{",
"sheetRelationshipsDrawingXML",
":=",
"\"",
"\"",
"+",
... | // prepareDrawing provides a function to prepare drawing ID and XML by given
// drawingID, worksheet name and default drawingXML. | [
"prepareDrawing",
"provides",
"a",
"function",
"to",
"prepare",
"drawing",
"ID",
"and",
"XML",
"by",
"given",
"drawingID",
"worksheet",
"name",
"and",
"default",
"drawingXML",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/chart.go#L490-L503 |
158,365 | 360EntSecGroup-Skylar/excelize | chart.go | addDrawingChart | func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rID int, formatSet *formatPicture) error {
col, row, err := CellNameToCoordinates(cell)
if err != nil {
return err
}
colIdx := col - 1
rowIdx := row - 1
width = int(float64(width) * formatSet.XScale)
height = int(float64(height) * formatSet.YScale)
colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 :=
f.positionObjectPixels(sheet, colIdx, rowIdx, formatSet.OffsetX, formatSet.OffsetY, width, height)
content, cNvPrID := f.drawingParser(drawingXML)
twoCellAnchor := xdrCellAnchor{}
twoCellAnchor.EditAs = formatSet.Positioning
from := xlsxFrom{}
from.Col = colStart
from.ColOff = formatSet.OffsetX * EMU
from.Row = rowStart
from.RowOff = formatSet.OffsetY * EMU
to := xlsxTo{}
to.Col = colEnd
to.ColOff = x2 * EMU
to.Row = rowEnd
to.RowOff = y2 * EMU
twoCellAnchor.From = &from
twoCellAnchor.To = &to
graphicFrame := xlsxGraphicFrame{
NvGraphicFramePr: xlsxNvGraphicFramePr{
CNvPr: &xlsxCNvPr{
ID: f.countCharts() + f.countMedia() + 1,
Name: "Chart " + strconv.Itoa(cNvPrID),
},
},
Graphic: &xlsxGraphic{
GraphicData: &xlsxGraphicData{
URI: NameSpaceDrawingMLChart,
Chart: &xlsxChart{
C: NameSpaceDrawingMLChart,
R: SourceRelationship,
RID: "rId" + strconv.Itoa(rID),
},
},
},
}
graphic, _ := xml.Marshal(graphicFrame)
twoCellAnchor.GraphicFrame = string(graphic)
twoCellAnchor.ClientData = &xdrClientData{
FLocksWithSheet: formatSet.FLocksWithSheet,
FPrintsWithSheet: formatSet.FPrintsWithSheet,
}
content.TwoCellAnchor = append(content.TwoCellAnchor, &twoCellAnchor)
f.Drawings[drawingXML] = content
return err
} | go | func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rID int, formatSet *formatPicture) error {
col, row, err := CellNameToCoordinates(cell)
if err != nil {
return err
}
colIdx := col - 1
rowIdx := row - 1
width = int(float64(width) * formatSet.XScale)
height = int(float64(height) * formatSet.YScale)
colStart, rowStart, _, _, colEnd, rowEnd, x2, y2 :=
f.positionObjectPixels(sheet, colIdx, rowIdx, formatSet.OffsetX, formatSet.OffsetY, width, height)
content, cNvPrID := f.drawingParser(drawingXML)
twoCellAnchor := xdrCellAnchor{}
twoCellAnchor.EditAs = formatSet.Positioning
from := xlsxFrom{}
from.Col = colStart
from.ColOff = formatSet.OffsetX * EMU
from.Row = rowStart
from.RowOff = formatSet.OffsetY * EMU
to := xlsxTo{}
to.Col = colEnd
to.ColOff = x2 * EMU
to.Row = rowEnd
to.RowOff = y2 * EMU
twoCellAnchor.From = &from
twoCellAnchor.To = &to
graphicFrame := xlsxGraphicFrame{
NvGraphicFramePr: xlsxNvGraphicFramePr{
CNvPr: &xlsxCNvPr{
ID: f.countCharts() + f.countMedia() + 1,
Name: "Chart " + strconv.Itoa(cNvPrID),
},
},
Graphic: &xlsxGraphic{
GraphicData: &xlsxGraphicData{
URI: NameSpaceDrawingMLChart,
Chart: &xlsxChart{
C: NameSpaceDrawingMLChart,
R: SourceRelationship,
RID: "rId" + strconv.Itoa(rID),
},
},
},
}
graphic, _ := xml.Marshal(graphicFrame)
twoCellAnchor.GraphicFrame = string(graphic)
twoCellAnchor.ClientData = &xdrClientData{
FLocksWithSheet: formatSet.FLocksWithSheet,
FPrintsWithSheet: formatSet.FPrintsWithSheet,
}
content.TwoCellAnchor = append(content.TwoCellAnchor, &twoCellAnchor)
f.Drawings[drawingXML] = content
return err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"addDrawingChart",
"(",
"sheet",
",",
"drawingXML",
",",
"cell",
"string",
",",
"width",
",",
"height",
",",
"rID",
"int",
",",
"formatSet",
"*",
"formatPicture",
")",
"error",
"{",
"col",
",",
"row",
",",
"err",
"... | // addDrawingChart provides a function to add chart graphic frame by given
// sheet, drawingXML, cell, width, height, relationship index and format sets. | [
"addDrawingChart",
"provides",
"a",
"function",
"to",
"add",
"chart",
"graphic",
"frame",
"by",
"given",
"sheet",
"drawingXML",
"cell",
"width",
"height",
"relationship",
"index",
"and",
"format",
"sets",
"."
] | 63e97ffc9aae35780cdbd69ad966fb101fc5217f | https://github.com/360EntSecGroup-Skylar/excelize/blob/63e97ffc9aae35780cdbd69ad966fb101fc5217f/chart.go#L1252-L1307 |
158,366 | casbin/casbin | enforcer_cached.go | NewCachedEnforcer | func NewCachedEnforcer(params ...interface{}) *CachedEnforcer {
e := &CachedEnforcer{}
e.Enforcer = NewEnforcer(params...)
e.enableCache = true
e.m = make(map[string]bool)
e.locker = new(sync.Mutex)
return e
} | go | func NewCachedEnforcer(params ...interface{}) *CachedEnforcer {
e := &CachedEnforcer{}
e.Enforcer = NewEnforcer(params...)
e.enableCache = true
e.m = make(map[string]bool)
e.locker = new(sync.Mutex)
return e
} | [
"func",
"NewCachedEnforcer",
"(",
"params",
"...",
"interface",
"{",
"}",
")",
"*",
"CachedEnforcer",
"{",
"e",
":=",
"&",
"CachedEnforcer",
"{",
"}",
"\n",
"e",
".",
"Enforcer",
"=",
"NewEnforcer",
"(",
"params",
"...",
")",
"\n",
"e",
".",
"enableCache... | // NewCachedEnforcer creates a cached enforcer via file or DB. | [
"NewCachedEnforcer",
"creates",
"a",
"cached",
"enforcer",
"via",
"file",
"or",
"DB",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_cached.go#L30-L37 |
158,367 | casbin/casbin | util/builtin_operators.go | KeyMatchFunc | func KeyMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch(name1, name2)), nil
} | go | func KeyMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch(name1, name2)), nil
} | [
"func",
"KeyMatchFunc",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"name1",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"name2",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"st... | // KeyMatchFunc is the wrapper for KeyMatch. | [
"KeyMatchFunc",
"is",
"the",
"wrapper",
"for",
"KeyMatch",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L40-L45 |
158,368 | casbin/casbin | util/builtin_operators.go | KeyMatch2Func | func KeyMatch2Func(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch2(name1, name2)), nil
} | go | func KeyMatch2Func(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch2(name1, name2)), nil
} | [
"func",
"KeyMatch2Func",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"name1",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"name2",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"s... | // KeyMatch2Func is the wrapper for KeyMatch2. | [
"KeyMatch2Func",
"is",
"the",
"wrapper",
"for",
"KeyMatch2",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L65-L70 |
158,369 | casbin/casbin | util/builtin_operators.go | KeyMatch3Func | func KeyMatch3Func(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch3(name1, name2)), nil
} | go | func KeyMatch3Func(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(KeyMatch3(name1, name2)), nil
} | [
"func",
"KeyMatch3Func",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"name1",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"name2",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"s... | // KeyMatch3Func is the wrapper for KeyMatch3. | [
"KeyMatch3Func",
"is",
"the",
"wrapper",
"for",
"KeyMatch3",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L90-L95 |
158,370 | casbin/casbin | util/builtin_operators.go | RegexMatch | func RegexMatch(key1 string, key2 string) bool {
res, err := regexp.MatchString(key2, key1)
if err != nil {
panic(err)
}
return res
} | go | func RegexMatch(key1 string, key2 string) bool {
res, err := regexp.MatchString(key2, key1)
if err != nil {
panic(err)
}
return res
} | [
"func",
"RegexMatch",
"(",
"key1",
"string",
",",
"key2",
"string",
")",
"bool",
"{",
"res",
",",
"err",
":=",
"regexp",
".",
"MatchString",
"(",
"key2",
",",
"key1",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
... | // RegexMatch determines whether key1 matches the pattern of key2 in regular expression. | [
"RegexMatch",
"determines",
"whether",
"key1",
"matches",
"the",
"pattern",
"of",
"key2",
"in",
"regular",
"expression",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L98-L104 |
158,371 | casbin/casbin | util/builtin_operators.go | RegexMatchFunc | func RegexMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(RegexMatch(name1, name2)), nil
} | go | func RegexMatchFunc(args ...interface{}) (interface{}, error) {
name1 := args[0].(string)
name2 := args[1].(string)
return bool(RegexMatch(name1, name2)), nil
} | [
"func",
"RegexMatchFunc",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"name1",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"name2",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"... | // RegexMatchFunc is the wrapper for RegexMatch. | [
"RegexMatchFunc",
"is",
"the",
"wrapper",
"for",
"RegexMatch",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L107-L112 |
158,372 | casbin/casbin | util/builtin_operators.go | IPMatchFunc | func IPMatchFunc(args ...interface{}) (interface{}, error) {
ip1 := args[0].(string)
ip2 := args[1].(string)
return bool(IPMatch(ip1, ip2)), nil
} | go | func IPMatchFunc(args ...interface{}) (interface{}, error) {
ip1 := args[0].(string)
ip2 := args[1].(string)
return bool(IPMatch(ip1, ip2)), nil
} | [
"func",
"IPMatchFunc",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"ip1",
":=",
"args",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"ip2",
":=",
"args",
"[",
"1",
"]",
".",
"(",
"string"... | // IPMatchFunc is the wrapper for IPMatch. | [
"IPMatchFunc",
"is",
"the",
"wrapper",
"for",
"IPMatch",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/util/builtin_operators.go#L136-L141 |
158,373 | casbin/casbin | management_api.go | GetAllNamedSubjects | func (e *Enforcer) GetAllNamedSubjects(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 0)
} | go | func (e *Enforcer) GetAllNamedSubjects(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 0)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetAllNamedSubjects",
"(",
"ptype",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetValuesForFieldInPolicy",
"(",
"\"",
"\"",
",",
"ptype",
",",
"0",
")",
"\n",
"}"
] | // GetAllNamedSubjects gets the list of subjects that show up in the current named policy. | [
"GetAllNamedSubjects",
"gets",
"the",
"list",
"of",
"subjects",
"that",
"show",
"up",
"in",
"the",
"current",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L23-L25 |
158,374 | casbin/casbin | management_api.go | GetAllNamedObjects | func (e *Enforcer) GetAllNamedObjects(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 1)
} | go | func (e *Enforcer) GetAllNamedObjects(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 1)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetAllNamedObjects",
"(",
"ptype",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetValuesForFieldInPolicy",
"(",
"\"",
"\"",
",",
"ptype",
",",
"1",
")",
"\n",
"}"
] | // GetAllNamedObjects gets the list of objects that show up in the current named policy. | [
"GetAllNamedObjects",
"gets",
"the",
"list",
"of",
"objects",
"that",
"show",
"up",
"in",
"the",
"current",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L33-L35 |
158,375 | casbin/casbin | management_api.go | GetAllNamedActions | func (e *Enforcer) GetAllNamedActions(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 2)
} | go | func (e *Enforcer) GetAllNamedActions(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("p", ptype, 2)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetAllNamedActions",
"(",
"ptype",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetValuesForFieldInPolicy",
"(",
"\"",
"\"",
",",
"ptype",
",",
"2",
")",
"\n",
"}"
] | // GetAllNamedActions gets the list of actions that show up in the current named policy. | [
"GetAllNamedActions",
"gets",
"the",
"list",
"of",
"actions",
"that",
"show",
"up",
"in",
"the",
"current",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L43-L45 |
158,376 | casbin/casbin | management_api.go | GetAllNamedRoles | func (e *Enforcer) GetAllNamedRoles(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("g", ptype, 1)
} | go | func (e *Enforcer) GetAllNamedRoles(ptype string) []string {
return e.model.GetValuesForFieldInPolicy("g", ptype, 1)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetAllNamedRoles",
"(",
"ptype",
"string",
")",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetValuesForFieldInPolicy",
"(",
"\"",
"\"",
",",
"ptype",
",",
"1",
")",
"\n",
"}"
] | // GetAllNamedRoles gets the list of roles that show up in the current named policy. | [
"GetAllNamedRoles",
"gets",
"the",
"list",
"of",
"roles",
"that",
"show",
"up",
"in",
"the",
"current",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L53-L55 |
158,377 | casbin/casbin | management_api.go | GetNamedPolicy | func (e *Enforcer) GetNamedPolicy(ptype string) [][]string {
return e.model.GetPolicy("p", ptype)
} | go | func (e *Enforcer) GetNamedPolicy(ptype string) [][]string {
return e.model.GetPolicy("p", ptype)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetNamedPolicy",
"(",
"ptype",
"string",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetPolicy",
"(",
"\"",
"\"",
",",
"ptype",
")",
"\n",
"}"
] | // GetNamedPolicy gets all the authorization rules in the named policy. | [
"GetNamedPolicy",
"gets",
"all",
"the",
"authorization",
"rules",
"in",
"the",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L68-L70 |
158,378 | casbin/casbin | management_api.go | GetFilteredNamedPolicy | func (e *Enforcer) GetFilteredNamedPolicy(ptype string, fieldIndex int, fieldValues ...string) [][]string {
return e.model.GetFilteredPolicy("p", ptype, fieldIndex, fieldValues...)
} | go | func (e *Enforcer) GetFilteredNamedPolicy(ptype string, fieldIndex int, fieldValues ...string) [][]string {
return e.model.GetFilteredPolicy("p", ptype, fieldIndex, fieldValues...)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetFilteredNamedPolicy",
"(",
"ptype",
"string",
",",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetFilteredPolicy",
"(",
"... | // GetFilteredNamedPolicy gets all the authorization rules in the named policy, field filters can be specified. | [
"GetFilteredNamedPolicy",
"gets",
"all",
"the",
"authorization",
"rules",
"in",
"the",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L73-L75 |
158,379 | casbin/casbin | management_api.go | GetFilteredGroupingPolicy | func (e *Enforcer) GetFilteredGroupingPolicy(fieldIndex int, fieldValues ...string) [][]string {
return e.GetFilteredNamedGroupingPolicy("g", fieldIndex, fieldValues...)
} | go | func (e *Enforcer) GetFilteredGroupingPolicy(fieldIndex int, fieldValues ...string) [][]string {
return e.GetFilteredNamedGroupingPolicy("g", fieldIndex, fieldValues...)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetFilteredGroupingPolicy",
"(",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"GetFilteredNamedGroupingPolicy",
"(",
"\"",
"\"",
",",
"fieldInde... | // GetFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified. | [
"GetFilteredGroupingPolicy",
"gets",
"all",
"the",
"role",
"inheritance",
"rules",
"in",
"the",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L83-L85 |
158,380 | casbin/casbin | management_api.go | GetNamedGroupingPolicy | func (e *Enforcer) GetNamedGroupingPolicy(ptype string) [][]string {
return e.model.GetPolicy("g", ptype)
} | go | func (e *Enforcer) GetNamedGroupingPolicy(ptype string) [][]string {
return e.model.GetPolicy("g", ptype)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"GetNamedGroupingPolicy",
"(",
"ptype",
"string",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"return",
"e",
".",
"model",
".",
"GetPolicy",
"(",
"\"",
"\"",
",",
"ptype",
")",
"\n",
"}"
] | // GetNamedGroupingPolicy gets all the role inheritance rules in the policy. | [
"GetNamedGroupingPolicy",
"gets",
"all",
"the",
"role",
"inheritance",
"rules",
"in",
"the",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L88-L90 |
158,381 | casbin/casbin | management_api.go | RemoveNamedPolicy | func (e *Enforcer) RemoveNamedPolicy(ptype string, params ...interface{}) bool {
var ruleRemoved bool
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
ruleRemoved = e.removePolicy("p", ptype, strSlice)
} else {
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
ruleRemoved = e.removePolicy("p", ptype, policy)
}
return ruleRemoved
} | go | func (e *Enforcer) RemoveNamedPolicy(ptype string, params ...interface{}) bool {
var ruleRemoved bool
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
ruleRemoved = e.removePolicy("p", ptype, strSlice)
} else {
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
ruleRemoved = e.removePolicy("p", ptype, policy)
}
return ruleRemoved
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"RemoveNamedPolicy",
"(",
"ptype",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"var",
"ruleRemoved",
"bool",
"\n",
"if",
"strSlice",
",",
"ok",
":=",
"params",
"[",
"0",
"]",
".",
"... | // RemoveNamedPolicy removes an authorization rule from the current named policy. | [
"RemoveNamedPolicy",
"removes",
"an",
"authorization",
"rule",
"from",
"the",
"current",
"named",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L153-L167 |
158,382 | casbin/casbin | management_api.go | RemoveFilteredNamedPolicy | func (e *Enforcer) RemoveFilteredNamedPolicy(ptype string, fieldIndex int, fieldValues ...string) bool {
return e.removeFilteredPolicy("p", ptype, fieldIndex, fieldValues...)
} | go | func (e *Enforcer) RemoveFilteredNamedPolicy(ptype string, fieldIndex int, fieldValues ...string) bool {
return e.removeFilteredPolicy("p", ptype, fieldIndex, fieldValues...)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"RemoveFilteredNamedPolicy",
"(",
"ptype",
"string",
",",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"bool",
"{",
"return",
"e",
".",
"removeFilteredPolicy",
"(",
"\"",
"\"",
",",
"ptype",
",",
"f... | // RemoveFilteredNamedPolicy removes an authorization rule from the current named policy, field filters can be specified. | [
"RemoveFilteredNamedPolicy",
"removes",
"an",
"authorization",
"rule",
"from",
"the",
"current",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L170-L172 |
158,383 | casbin/casbin | management_api.go | HasNamedGroupingPolicy | func (e *Enforcer) HasNamedGroupingPolicy(ptype string, params ...interface{}) bool {
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
return e.model.HasPolicy("g", ptype, strSlice)
}
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
return e.model.HasPolicy("g", ptype, policy)
} | go | func (e *Enforcer) HasNamedGroupingPolicy(ptype string, params ...interface{}) bool {
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
return e.model.HasPolicy("g", ptype, strSlice)
}
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
return e.model.HasPolicy("g", ptype, policy)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"HasNamedGroupingPolicy",
"(",
"ptype",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"if",
"strSlice",
",",
"ok",
":=",
"params",
"[",
"0",
"]",
".",
"(",
"[",
"]",
"string",
")",
... | // HasNamedGroupingPolicy determines whether a named role inheritance rule exists. | [
"HasNamedGroupingPolicy",
"determines",
"whether",
"a",
"named",
"role",
"inheritance",
"rule",
"exists",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L180-L191 |
158,384 | casbin/casbin | management_api.go | AddNamedGroupingPolicy | func (e *Enforcer) AddNamedGroupingPolicy(ptype string, params ...interface{}) bool {
var ruleAdded bool
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
ruleAdded = e.addPolicy("g", ptype, strSlice)
} else {
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
ruleAdded = e.addPolicy("g", ptype, policy)
}
if e.autoBuildRoleLinks {
e.BuildRoleLinks()
}
return ruleAdded
} | go | func (e *Enforcer) AddNamedGroupingPolicy(ptype string, params ...interface{}) bool {
var ruleAdded bool
if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
ruleAdded = e.addPolicy("g", ptype, strSlice)
} else {
policy := make([]string, 0)
for _, param := range params {
policy = append(policy, param.(string))
}
ruleAdded = e.addPolicy("g", ptype, policy)
}
if e.autoBuildRoleLinks {
e.BuildRoleLinks()
}
return ruleAdded
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"AddNamedGroupingPolicy",
"(",
"ptype",
"string",
",",
"params",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"var",
"ruleAdded",
"bool",
"\n",
"if",
"strSlice",
",",
"ok",
":=",
"params",
"[",
"0",
"]",
".",
... | // AddNamedGroupingPolicy adds a named role inheritance rule to the current policy.
// If the rule already exists, the function returns false and the rule will not be added.
// Otherwise the function returns true by adding the new rule. | [
"AddNamedGroupingPolicy",
"adds",
"a",
"named",
"role",
"inheritance",
"rule",
"to",
"the",
"current",
"policy",
".",
"If",
"the",
"rule",
"already",
"exists",
"the",
"function",
"returns",
"false",
"and",
"the",
"rule",
"will",
"not",
"be",
"added",
".",
"O... | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L203-L220 |
158,385 | casbin/casbin | management_api.go | RemoveFilteredGroupingPolicy | func (e *Enforcer) RemoveFilteredGroupingPolicy(fieldIndex int, fieldValues ...string) bool {
return e.RemoveFilteredNamedGroupingPolicy("g", fieldIndex, fieldValues...)
} | go | func (e *Enforcer) RemoveFilteredGroupingPolicy(fieldIndex int, fieldValues ...string) bool {
return e.RemoveFilteredNamedGroupingPolicy("g", fieldIndex, fieldValues...)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"RemoveFilteredGroupingPolicy",
"(",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"bool",
"{",
"return",
"e",
".",
"RemoveFilteredNamedGroupingPolicy",
"(",
"\"",
"\"",
",",
"fieldIndex",
",",
"fieldValue... | // RemoveFilteredGroupingPolicy removes a role inheritance rule from the current policy, field filters can be specified. | [
"RemoveFilteredGroupingPolicy",
"removes",
"a",
"role",
"inheritance",
"rule",
"from",
"the",
"current",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L228-L230 |
158,386 | casbin/casbin | management_api.go | RemoveFilteredNamedGroupingPolicy | func (e *Enforcer) RemoveFilteredNamedGroupingPolicy(ptype string, fieldIndex int, fieldValues ...string) bool {
ruleRemoved := e.removeFilteredPolicy("g", ptype, fieldIndex, fieldValues...)
if e.autoBuildRoleLinks {
e.BuildRoleLinks()
}
return ruleRemoved
} | go | func (e *Enforcer) RemoveFilteredNamedGroupingPolicy(ptype string, fieldIndex int, fieldValues ...string) bool {
ruleRemoved := e.removeFilteredPolicy("g", ptype, fieldIndex, fieldValues...)
if e.autoBuildRoleLinks {
e.BuildRoleLinks()
}
return ruleRemoved
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"RemoveFilteredNamedGroupingPolicy",
"(",
"ptype",
"string",
",",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"bool",
"{",
"ruleRemoved",
":=",
"e",
".",
"removeFilteredPolicy",
"(",
"\"",
"\"",
",",
... | // RemoveFilteredNamedGroupingPolicy removes a role inheritance rule from the current named policy, field filters can be specified. | [
"RemoveFilteredNamedGroupingPolicy",
"removes",
"a",
"role",
"inheritance",
"rule",
"from",
"the",
"current",
"named",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L253-L260 |
158,387 | casbin/casbin | management_api.go | AddFunction | func (e *Enforcer) AddFunction(name string, function func(args ...interface{}) (interface{}, error)) {
e.fm.AddFunction(name, function)
} | go | func (e *Enforcer) AddFunction(name string, function func(args ...interface{}) (interface{}, error)) {
e.fm.AddFunction(name, function)
} | [
"func",
"(",
"e",
"*",
"Enforcer",
")",
"AddFunction",
"(",
"name",
"string",
",",
"function",
"func",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
")",
"{",
"e",
".",
"fm",
".",
"AddFunction",
"(",... | // AddFunction adds a customized function. | [
"AddFunction",
"adds",
"a",
"customized",
"function",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/management_api.go#L263-L265 |
158,388 | casbin/casbin | enforcer_synced.go | NewSyncedEnforcer | func NewSyncedEnforcer(params ...interface{}) *SyncedEnforcer {
e := &SyncedEnforcer{}
e.Enforcer = NewEnforcer(params...)
e.autoLoad = false
return e
} | go | func NewSyncedEnforcer(params ...interface{}) *SyncedEnforcer {
e := &SyncedEnforcer{}
e.Enforcer = NewEnforcer(params...)
e.autoLoad = false
return e
} | [
"func",
"NewSyncedEnforcer",
"(",
"params",
"...",
"interface",
"{",
"}",
")",
"*",
"SyncedEnforcer",
"{",
"e",
":=",
"&",
"SyncedEnforcer",
"{",
"}",
"\n",
"e",
".",
"Enforcer",
"=",
"NewEnforcer",
"(",
"params",
"...",
")",
"\n",
"e",
".",
"autoLoad",
... | // NewSyncedEnforcer creates a synchronized enforcer via file or DB. | [
"NewSyncedEnforcer",
"creates",
"a",
"synchronized",
"enforcer",
"via",
"file",
"or",
"DB",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L33-L38 |
158,389 | casbin/casbin | enforcer_synced.go | StartAutoLoadPolicy | func (e *SyncedEnforcer) StartAutoLoadPolicy(d time.Duration) {
e.autoLoad = true
go func() {
n := 1
log.Print("Start automatically load policy")
for {
if !e.autoLoad {
log.Print("Stop automatically load policy")
break
}
// error intentionally ignored
e.LoadPolicy()
// Uncomment this line to see when the policy is loaded.
// log.Print("Load policy for time: ", n)
n++
time.Sleep(d)
}
}()
} | go | func (e *SyncedEnforcer) StartAutoLoadPolicy(d time.Duration) {
e.autoLoad = true
go func() {
n := 1
log.Print("Start automatically load policy")
for {
if !e.autoLoad {
log.Print("Stop automatically load policy")
break
}
// error intentionally ignored
e.LoadPolicy()
// Uncomment this line to see when the policy is loaded.
// log.Print("Load policy for time: ", n)
n++
time.Sleep(d)
}
}()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"StartAutoLoadPolicy",
"(",
"d",
"time",
".",
"Duration",
")",
"{",
"e",
".",
"autoLoad",
"=",
"true",
"\n",
"go",
"func",
"(",
")",
"{",
"n",
":=",
"1",
"\n",
"log",
".",
"Print",
"(",
"\"",
"\"",
")... | // StartAutoLoadPolicy starts a go routine that will every specified duration call LoadPolicy | [
"StartAutoLoadPolicy",
"starts",
"a",
"go",
"routine",
"that",
"will",
"every",
"specified",
"duration",
"call",
"LoadPolicy"
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L41-L60 |
158,390 | casbin/casbin | enforcer_synced.go | SetWatcher | func (e *SyncedEnforcer) SetWatcher(watcher persist.Watcher) {
e.watcher = watcher
// error intentionally ignored
watcher.SetUpdateCallback(func(string) { e.LoadPolicy() })
} | go | func (e *SyncedEnforcer) SetWatcher(watcher persist.Watcher) {
e.watcher = watcher
// error intentionally ignored
watcher.SetUpdateCallback(func(string) { e.LoadPolicy() })
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"SetWatcher",
"(",
"watcher",
"persist",
".",
"Watcher",
")",
"{",
"e",
".",
"watcher",
"=",
"watcher",
"\n",
"// error intentionally ignored",
"watcher",
".",
"SetUpdateCallback",
"(",
"func",
"(",
"string",
")",
... | // SetWatcher sets the current watcher. | [
"SetWatcher",
"sets",
"the",
"current",
"watcher",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L68-L72 |
158,391 | casbin/casbin | enforcer_synced.go | ClearPolicy | func (e *SyncedEnforcer) ClearPolicy() {
e.m.Lock()
defer e.m.Unlock()
e.Enforcer.ClearPolicy()
} | go | func (e *SyncedEnforcer) ClearPolicy() {
e.m.Lock()
defer e.m.Unlock()
e.Enforcer.ClearPolicy()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"ClearPolicy",
"(",
")",
"{",
"e",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"e",
".",
"Enforcer",
".",
"ClearPolicy",
"(",
")",
"\n",
"}"
] | // ClearPolicy clears all policy. | [
"ClearPolicy",
"clears",
"all",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L75-L79 |
158,392 | casbin/casbin | enforcer_synced.go | GetAllSubjects | func (e *SyncedEnforcer) GetAllSubjects() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllSubjects()
} | go | func (e *SyncedEnforcer) GetAllSubjects() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllSubjects()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetAllSubjects",
"(",
")",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
".",
"GetAllSu... | // GetAllSubjects gets the list of subjects that show up in the current policy. | [
"GetAllSubjects",
"gets",
"the",
"list",
"of",
"subjects",
"that",
"show",
"up",
"in",
"the",
"current",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L110-L114 |
158,393 | casbin/casbin | enforcer_synced.go | GetAllObjects | func (e *SyncedEnforcer) GetAllObjects() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllObjects()
} | go | func (e *SyncedEnforcer) GetAllObjects() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllObjects()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetAllObjects",
"(",
")",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
".",
"GetAllObj... | // GetAllObjects gets the list of objects that show up in the current policy. | [
"GetAllObjects",
"gets",
"the",
"list",
"of",
"objects",
"that",
"show",
"up",
"in",
"the",
"current",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L117-L121 |
158,394 | casbin/casbin | enforcer_synced.go | GetAllActions | func (e *SyncedEnforcer) GetAllActions() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllActions()
} | go | func (e *SyncedEnforcer) GetAllActions() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllActions()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetAllActions",
"(",
")",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
".",
"GetAllAct... | // GetAllActions gets the list of actions that show up in the current policy. | [
"GetAllActions",
"gets",
"the",
"list",
"of",
"actions",
"that",
"show",
"up",
"in",
"the",
"current",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L124-L128 |
158,395 | casbin/casbin | enforcer_synced.go | GetAllRoles | func (e *SyncedEnforcer) GetAllRoles() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllRoles()
} | go | func (e *SyncedEnforcer) GetAllRoles() []string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetAllRoles()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetAllRoles",
"(",
")",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
".",
"GetAllRoles... | // GetAllRoles gets the list of roles that show up in the current policy. | [
"GetAllRoles",
"gets",
"the",
"list",
"of",
"roles",
"that",
"show",
"up",
"in",
"the",
"current",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L131-L135 |
158,396 | casbin/casbin | enforcer_synced.go | GetPolicy | func (e *SyncedEnforcer) GetPolicy() [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetPolicy()
} | go | func (e *SyncedEnforcer) GetPolicy() [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetPolicy()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetPolicy",
"(",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
".",
... | // GetPolicy gets all the authorization rules in the policy. | [
"GetPolicy",
"gets",
"all",
"the",
"authorization",
"rules",
"in",
"the",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L138-L142 |
158,397 | casbin/casbin | enforcer_synced.go | GetFilteredPolicy | func (e *SyncedEnforcer) GetFilteredPolicy(fieldIndex int, fieldValues ...string) [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetFilteredPolicy(fieldIndex, fieldValues...)
} | go | func (e *SyncedEnforcer) GetFilteredPolicy(fieldIndex int, fieldValues ...string) [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetFilteredPolicy(fieldIndex, fieldValues...)
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetFilteredPolicy",
"(",
"fieldIndex",
"int",
",",
"fieldValues",
"...",
"string",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUn... | // GetFilteredPolicy gets all the authorization rules in the policy, field filters can be specified. | [
"GetFilteredPolicy",
"gets",
"all",
"the",
"authorization",
"rules",
"in",
"the",
"policy",
"field",
"filters",
"can",
"be",
"specified",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L145-L149 |
158,398 | casbin/casbin | enforcer_synced.go | GetGroupingPolicy | func (e *SyncedEnforcer) GetGroupingPolicy() [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetGroupingPolicy()
} | go | func (e *SyncedEnforcer) GetGroupingPolicy() [][]string {
e.m.RLock()
defer e.m.RUnlock()
return e.Enforcer.GetGroupingPolicy()
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"GetGroupingPolicy",
"(",
")",
"[",
"]",
"[",
"]",
"string",
"{",
"e",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"return",
"e",
".",
"Enforcer",
... | // GetGroupingPolicy gets all the role inheritance rules in the policy. | [
"GetGroupingPolicy",
"gets",
"all",
"the",
"role",
"inheritance",
"rules",
"in",
"the",
"policy",
"."
] | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L152-L156 |
158,399 | casbin/casbin | enforcer_synced.go | AddPolicy | func (e *SyncedEnforcer) AddPolicy(params ...interface{}) bool {
e.m.Lock()
defer e.m.Unlock()
return e.Enforcer.AddPolicy(params...)
} | go | func (e *SyncedEnforcer) AddPolicy(params ...interface{}) bool {
e.m.Lock()
defer e.m.Unlock()
return e.Enforcer.AddPolicy(params...)
} | [
"func",
"(",
"e",
"*",
"SyncedEnforcer",
")",
"AddPolicy",
"(",
"params",
"...",
"interface",
"{",
"}",
")",
"bool",
"{",
"e",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"m",
".",
"Unlock",
"(",
")",
"\n",
"return",
"e",
".",
"En... | // AddPolicy adds an authorization rule to the current policy.
// If the rule already exists, the function returns false and the rule will not be added.
// Otherwise the function returns true by adding the new rule. | [
"AddPolicy",
"adds",
"an",
"authorization",
"rule",
"to",
"the",
"current",
"policy",
".",
"If",
"the",
"rule",
"already",
"exists",
"the",
"function",
"returns",
"false",
"and",
"the",
"rule",
"will",
"not",
"be",
"added",
".",
"Otherwise",
"the",
"function... | 9814ac94c19c922c0afd5c2f34255e0d543ef372 | https://github.com/casbin/casbin/blob/9814ac94c19c922c0afd5c2f34255e0d543ef372/enforcer_synced.go#L175-L179 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.