Skip to content

Commit 1633f63

Browse files
add API document
1 parent 7746644 commit 1633f63

File tree

1 file changed

+45
-4
lines changed
  • libxlsxwriter/src/worksheet

1 file changed

+45
-4
lines changed

libxlsxwriter/src/worksheet/mod.rs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,9 +1250,12 @@ impl<'a> Worksheet<'a> {
12501250
/// The Worksheet.insert_image_opt() function takes additional optional parameters to position and scale the image, see below.
12511251
///
12521252
/// ### Note
1253-
/// The scaling of a image may be affected if is crosses a row that has its default height changed due to a font that is larger than the default font size or that has text wrapping turned on. To avoid this you should explicitly set the height of the row using Worksheet.set_row() if it crosses an inserted image.
1253+
/// The scaling of a image may be affected if is crosses a row that has its default height changed due to a font that is larger than
1254+
/// the default font size or that has text wrapping turned on. To avoid this you should explicitly set the height of the row using
1255+
/// [`Worksheet::set_row`] if it crosses an inserted image.
12541256
///
1255-
/// BMP images are only supported for backward compatibility. In general it is best to avoid BMP images since they aren't compressed. If used, BMP images must be 24 bit, true color, bitmaps.
1257+
/// BMP images are only supported for backward compatibility. In general it is best to avoid BMP images since they aren't compressed.
1258+
/// If used, BMP images must be 24 bit, true color, bitmaps.
12561259
pub fn insert_image(
12571260
&mut self,
12581261
row: WorksheetRow,
@@ -1296,7 +1299,7 @@ impl<'a> Worksheet<'a> {
12961299
/// ![Result Image](https://github.com/informationsea/xlsxwriter-rs/raw/master/images/test-worksheet-insert_image_opt-1.png)
12971300
///
12981301
/// ### Note
1299-
/// See the notes about row scaling and BMP images in Worksheet.insert_image() above.
1302+
/// See the notes about row scaling and BMP images in [`Worksheet::insert_image`] above.
13001303
pub fn insert_image_opt(
13011304
&mut self,
13021305
row: WorksheetRow,
@@ -1332,7 +1335,7 @@ impl<'a> Worksheet<'a> {
13321335
/// # workbook.close()
13331336
/// # }
13341337
/// ```
1335-
/// See Worksheet.insert_image() for details about the supported image formats, and other image features.
1338+
/// See [`Worksheet::insert_image`] for details about the supported image formats, and other image features.
13361339
pub fn insert_image_buffer(
13371340
&mut self,
13381341
row: WorksheetRow,
@@ -1397,6 +1400,7 @@ impl<'a> Worksheet<'a> {
13971400
}
13981401
}
13991402

1403+
/// The [`Worksheet::merge_range`] function allows cells to be merged together so that they act as a single area.
14001404
pub fn merge_range(
14011405
&mut self,
14021406
first_row: WorksheetRow,
@@ -1424,42 +1428,79 @@ impl<'a> Worksheet<'a> {
14241428
}
14251429
}
14261430

1431+
/// The [`Worksheet::activate`] function is used to specify which worksheet is initially visible in a multi-sheet workbook.
14271432
pub fn activate(&mut self) {
14281433
unsafe {
14291434
libxlsxwriter_sys::worksheet_activate(self.worksheet);
14301435
}
14311436
}
14321437

1438+
/// The [`Worksheet::select`] function is used to indicate that a worksheet is selected in a multi-sheet workbook.
1439+
///
1440+
/// A selected worksheet has its tab highlighted. Selecting worksheets is a way of grouping them together so that, for example, several worksheets could be printed in one go.
1441+
/// A worksheet that has been activated via the [`Worksheet::activate`] function will also appear as selected.
14331442
pub fn select(&mut self) {
14341443
unsafe {
14351444
libxlsxwriter_sys::worksheet_select(self.worksheet);
14361445
}
14371446
}
14381447

1448+
/// The [`Worksheet::hide`] function is used to hide a worksheet.
1449+
///
1450+
/// You may wish to hide a worksheet in order to avoid confusing a user with intermediate data or calculations.
1451+
///
1452+
/// A hidden worksheet can not be activated or selected so this function is mutually exclusive with the [`Worksheet::activate`]
1453+
/// and [`Worksheet::select`] functions. In addition, since the first worksheet will default to being the active worksheet,
1454+
/// you cannot hide the first worksheet without activating another sheet.
14391455
pub fn hide(&mut self) {
14401456
unsafe {
14411457
libxlsxwriter_sys::worksheet_hide(self.worksheet);
14421458
}
14431459
}
14441460

1461+
/// The [`Worksheet::activate`] function determines which worksheet is initially selected. However,
1462+
/// if there are a large number of worksheets the selected worksheet may not appear on the screen.
1463+
/// To avoid this you can select the leftmost visible worksheet tab using [`Worksheet::set_first_sheet`]
1464+
///
1465+
/// This function is not required very often. The default value is the first worksheet.
14451466
pub fn set_first_sheet(&mut self) {
14461467
unsafe {
14471468
libxlsxwriter_sys::worksheet_set_first_sheet(self.worksheet);
14481469
}
14491470
}
14501471

1472+
/// The [`Worksheet::freeze_panes`] function can be used to divide a worksheet into horizontal or
1473+
/// vertical regions known as panes and to "freeze" these panes so that the splitter bars are not visible.
1474+
///
1475+
/// The parameters row and col are used to specify the location of the split. It should be noted that the
1476+
/// split is specified at the top or left of a cell and that the function uses zero based indexing. Therefore
1477+
/// to freeze the first row of a worksheet it is necessary to specify the split at row 2 (which is 1 as the zero-based index).
1478+
///
1479+
/// You can set one of the row and col parameters as zero if you do not want either a vertical or horizontal split.
14511480
pub fn freeze_panes(&mut self, row: WorksheetRow, col: WorksheetCol) {
14521481
unsafe {
14531482
libxlsxwriter_sys::worksheet_freeze_panes(self.worksheet, row, col);
14541483
}
14551484
}
14561485

1486+
/// The [`Worksheet::split_panes`] function can be used to divide a worksheet into horizontal or vertical regions known as panes.
1487+
/// This function is different from the [`Worksheet::freeze_panes`] function in that the splits between the panes will be visible
1488+
/// to the user and each pane will have its own scroll bars.
1489+
///
1490+
/// The parameters vertical and horizontal are used to specify the vertical and horizontal position of the split. The units for
1491+
/// vertical and horizontal are the same as those used by Excel to specify row height and column width. However, the vertical
1492+
/// and horizontal units are different from each other. Therefore you must specify the vertical and horizontal parameters in
1493+
/// terms of the row heights and column widths that you have set or the default values which are 15 for a row and 8.43 for a column.
14571494
pub fn split_panes(&mut self, vertical: f64, horizontal: f64) {
14581495
unsafe {
14591496
libxlsxwriter_sys::worksheet_split_panes(self.worksheet, vertical, horizontal);
14601497
}
14611498
}
14621499

1500+
/// The [`Worksheet::set_selection`] function can be used to specify which cell or range of cells is selected in a worksheet:
1501+
/// The most common requirement is to select a single cell, in which case the first_ and last_ parameters should be the same.
1502+
///
1503+
/// The active cell within a selected range is determined by the order in which `first_` and `last_` are specified.
14631504
pub fn set_selection(
14641505
&mut self,
14651506
first_row: WorksheetRow,

0 commit comments

Comments
 (0)