Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adjust.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ func (f *File) adjustDataValidations(ws *xlsxWorksheet, sheet string, dir adjust
return err
}
if worksheet.DataValidations == nil {
return nil
continue
}
for i := 0; i < len(worksheet.DataValidations.DataValidation); i++ {
dv := worksheet.DataValidations.DataValidation[i]
Expand Down
19 changes: 19 additions & 0 deletions adjust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,25 @@ func TestAdjustDataValidations(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, formula, dvs[0].Formula1)
})

t.Run("no_data_validations_on_first_sheet", func(t *testing.T) {
f := NewFile()

// Add Sheet2 and set a data validation
_, err = f.NewSheet("Sheet2")
assert.NoError(t, err)
dv := NewDataValidation(true)
dv.Sqref = "C5:D6"
assert.NoError(t, f.AddDataValidation("Sheet2", dv))

// Adjust Sheet2 by removing a column
assert.NoError(t, f.RemoveCol("Sheet2", "A"))

// Verify that data validations on Sheet2 are adjusted correctly
dvs, err = f.GetDataValidations("Sheet2")
assert.NoError(t, err)
assert.Equal(t, "B5:C6", dvs[0].Sqref) // Adjusted range
})
}

func TestAdjustDrawings(t *testing.T) {
Expand Down