How is your experience with the OutSystems Community?
16
Views
5
Comments
 when i upload excel with multiplesheet need to pick exact sheet and updatedatabase
Question

i have a requirement where i have excel which as multiple sheet based on i have to pickspecific sheet name and then update data base   issues is that even if sheetname has extra space or uppercase gives an error saying sheet not found

2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Navya Vani ,

You can use ToLower() and Trim() to make the worksheet-name comparison more flexible:

  • ToLower() makes the comparison case-insensitive, so "Sheet1" and "SHEET1" are treated as the same name.
  • Trim() removes leading and trailing spaces, so " Sheet1 " matches "Sheet1".

Before calling Worksheet_SelectByName, use Workbook_GetProperties to retrieve the properties and names of all worksheets in the workbook. Then use ListIndex to search for the required worksheet using ToLower() and Trim(). Example:

 ToLower(Trim(WorksheetList.Current.Name)) = ToLower(Trim(ExpectedSheetName)) 

If ListIndex.Position = -1, the worksheet was not found. You can stop the flow and display an error.

If it is found, retrieve the original worksheet name using the returned position:

WorksheetList[ListIndex.Position].Name

Pass this value to Worksheet_SelectByName.

UserImage.jpg
Navya Vani

how to get all sheet names...??
wht if user gives extraspace after sheetname  


2026-01-28 16-57-48
Mihai Melencu
Champion

You can use Workbook_GetProperties action to get all sheet names. You can use Trim() to remove extra spaces before and after the sheet name.

2023-12-11 06-11-39
Mohammad Shad

Hi @Navya Vani ,

You can follow the approach Mihai mentioned. If you need a working solution, please share the OML file.


2025-08-07 06-30-56
Amit J
Champion

@Navya Vani


The problem is that Worksheet_Select_ByName (and similar activities) do an exact string match against sheet names, so "Sheet1 " or "SHEET1" won't match "Sheet1".

Fix: don't pass the raw name straight in — get the workbook's actual sheet names first, then find the matching one using a trimmed/case-insensitive comparison.

Steps:

  1. After Workbook_Open_BinaryData, add a Get Sheets / Workbook_Get_SheetNames type activity (or use Excel.Workbook.SheetNames if you have direct access) → gives you List<String> allSheets.
  2. Before calling Worksheet_Select_ByName, compute the real sheet name:

matchedSheet = allSheets.Where(Function(s) s.Trim().ToUpper() = inputSheetName.Trim().ToUpper()).FirstOrDefault()

  1. If matchedSheet is Nothing/empty → throw your own "Sheet not found" (real check), else pass matchedSheet (the exact name from the workbook) into Worksheet_Select_ByName instead of the raw user-provided name.

This way, whatever casing/spacing the user typed, you always feed the activity the exact string Excel actually has, so it stops failing on trivial formatting differences.

If your activity set doesn't expose "get all sheet names" directly, you can get it via the Workbook_Open output object (its Sheets/SheetNames property) — check what's on your Workbook_Open result variable, since most Excel activity packages expose this.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.