{"record":{"id":"33565fadb7babeb8","repo":"qax-os/excelize","slug":"errsheetnamesinglequote","errorCode":"ErrSheetNameSingleQuote","errorMessage":"the first or last character of the sheet name can not be a single quote","messagePattern":"the first or last character of the sheet name can not be a single quote","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":155,"sourceCode":"\t// ClassicLayout and CompactData in the same time.\n\tErrPivotTableClassicLayout = errors.New(\"cannot enable ClassicLayout and CompactData in the same time\")\n\t// ErrSave defined the error message for saving file.\n\tErrSave = errors.New(\"no path defined for file, consider File.WriteTo or File.Write\")\n\t// ErrSheetIdx defined the error message on receive the invalid worksheet\n\t// index.\n\tErrSheetIdx = errors.New(\"invalid worksheet index\")\n\t// ErrSheetNameBlank defined the error message on receive the blank sheet\n\t// name.\n\tErrSheetNameBlank = errors.New(\"the sheet name can not be blank\")\n\t// ErrSheetNameInvalid defined the error message on receive the sheet name\n\t// contains invalid characters.\n\tErrSheetNameInvalid = errors.New(\"the sheet can not contain any of the characters :\\\\/?*[or]\")\n\t// ErrSheetNameLength defined the error message on receiving the sheet\n\t// name length exceeds the limit.\n\tErrSheetNameLength = fmt.Errorf(\"the sheet name length exceeds the %d characters limit\", MaxSheetNameLength)\n\t// ErrSheetNameSingleQuote defined the error message on the first or last\n\t// character of the sheet name was a single quote.\n\tErrSheetNameSingleQuote = errors.New(\"the first or last character of the sheet name can not be a single quote\")\n\t// ErrSparkline defined the error message on receive the invalid sparkline\n\t// parameters.\n\tErrSparkline = errors.New(\"must have the same number of 'Location' and 'Range' parameters\")\n\t// ErrSparklineLocation defined the error message on missing Location\n\t// parameters\n\tErrSparklineLocation = errors.New(\"parameter 'Location' is required\")\n\t// ErrSparklineRange defined the error message on missing sparkline Range\n\t// parameters\n\tErrSparklineRange = errors.New(\"parameter 'Range' is required\")\n\t// ErrSparklineStyle defined the error message on receive the invalid\n\t// sparkline Style parameters.\n\tErrSparklineStyle = errors.New(\"parameter 'Style' value must be an integer from 0 to 35\")\n\t// ErrSparklineType defined the error message on receive the invalid\n\t// sparkline Type parameters.\n\tErrSparklineType = errors.New(\"parameter 'Type' value must be one of 'line', 'column' or 'win_loss'\")\n\t// ErrTotalSheetHyperlinks defined the error message on hyperlinks count\n\t// overflow.\n\tErrTotalSheetHyperlinks = errors.New(\"over maximum limit hyperlinks in a worksheet\")","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L137-L173","documentation":"ErrSheetNameSingleQuote is returned when a worksheet name starts or ends with a single quote ('). checkSheetName (sheet.go:1520) rejects this because Excel reserves surrounding single quotes for quoting sheet names in formulas and references.","triggerScenarios":"Calling any sheet-creating or sheet-naming API (NewSheet, SetSheetName, etc.) with names like \"'Sheet\" or \"Sheet'\"; passing such names through checkSheetName via validation helpers.","commonSituations":"Programmatically quoting sheet names for formulas and accidentally including the quotes in the stored name; copying names from formula strings like 'My Sheet'!A1.","solutions":["Trim leading/trailing single quotes with strings.Trim(name, \"'\") before use","Do not pre-quote sheet names; the library quotes them itself when writing formulas","Validate with strings.HasPrefix(name, \"'\") || strings.HasSuffix(name, \"'\") before calling the API"],"exampleFix":"// before\nidx, err := f.NewSheet(\"'My Sheet'\")\n// after\nidx, err := f.NewSheet(strings.Trim(rawName, \"'\"))","handlingStrategy":"validation","validationCode":"if strings.HasPrefix(name, \"'\") || strings.HasSuffix(name, \"'\") {\n    return errors.New(\"sheet name must not start or end with a single quote\")\n}","typeGuard":"func validSheetName(name string) bool {\n    return name != \"\" && !strings.ContainsAny(name, \":\\\\/?*[]\") &&\n        !strings.HasPrefix(name, \"'\") && !strings.HasSuffix(name, \"'\")\n}","tryCatchPattern":"if err := check; errors.Is(err, excelize.ErrSheetNameSingleQuote) {\n    name = strings.Trim(name, \"'\")\n    // retry with trimmed name\n}","preventionTips":["Never wrap sheet names in quotes yourself; the library quotes when needed","strings.Trim(name, \"'\") on any name extracted from formula text","Include quote checks in your sheet-name validation helper"],"tags":["go","excelize","sheet-name","validation"],"backgroundTag":"invalid-sheet-name-characters","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}