TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gordana Tasic
1.6k
96
13.7k
How to protect certain columns in an Excel file from modifications?
Mar 21 2021 4:09 PM
I'm creating an Excel file using C#, but I want some columns to be protected from modification. The problem is that I don't know how many rows I'm going to have in that file. I used the following code,I know there is a Range, but I need a universal solution when I don't know how many rows an Excel file has:
xlWorkSheet.Cells.Locked =
false
;
xlWorkSheet.Range[
"A1:A3"
].Locked =
true
;
xlWorkSheet.Range[
"B1"
].Locked =
true
;
xlWorkSheet.Range[
"C1"
].Locked =
true
;
xlWorkSheet.Range[
"D1:D3"
].Locked =
true
;
xlWorkSheet.Range[
"E1:E3"
].Locked =
true
;
xlWorkSheet.Range[
"F1:F3"
].Locked =
true
;
xlWorkSheet.Protect(misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
Reply
Answers (
1
)
Convert captured image into binary by webcam.
How to apply template on excel file exported using oledb ?